Fixes category checkbox error, Changes Log Description and Title, Fixes css of pagination component

This commit is contained in:
weryques 2018-04-04 14:41:06 -03:00
parent a3a239a435
commit aae26b4cf7
6 changed files with 44 additions and 12 deletions

View File

@ -12,7 +12,7 @@
:events="events"/> :events="events"/>
<!-- Footer --> <!-- Footer -->
<div <div
class="table-footer" class="pagination-area"
v-if="totalEvents > 0"> v-if="totalEvents > 0">
<div class="shown-items"> <div class="shown-items">
{{ {{

View File

@ -219,13 +219,13 @@ class Entity {
foreach ($prop_value as $val) { foreach ($prop_value as $val) {
if (!$validation->validate($val)) { if (!$validation->validate($val)) {
$this->add_error($prop, $message); $this->add_error($this->get_id() .' '. $prop, $message);
$is_valid = false; $is_valid = false;
} }
} }
} else { } else {
if (!$validation->validate($prop_value)) { if (!$validation->validate($prop_value)) {
$this->add_error($prop, $message); $this->add_error($this->get_id() .' '. $prop, $message);
$is_valid = false; $is_valid = false;
} }
} }

View File

@ -43,7 +43,20 @@ class Item_Metadata_Entity extends Entity {
} }
public function __toArray(){ public function __toArray(){
$value = $this->get_value();
if(is_array($value) && $value[0] instanceof Term){
$values_arr = [];
foreach ($value as $val){
$values_arr[] = $val->__toArray();
}
$as_array['value'] = $values_arr;
} else {
$as_array['value'] = $this->get_value(); $as_array['value'] = $this->get_value();
}
$as_array['item'] = $this->get_item()->__toArray(); $as_array['item'] = $this->get_item()->__toArray();
$as_array['field'] = $this->get_field()->__toArray(); $as_array['field'] = $this->get_field()->__toArray();

View File

@ -90,7 +90,7 @@
getValue(){ getValue(){
if (this.field.value instanceof Array) { if (this.field.value instanceof Array) {
this.inputs = this.field.value; this.inputs = this.field.value;
if (this.inputs.length == 0) if (this.inputs.length === 0)
this.inputs.push(''); this.inputs.push('');
} else { } else {
this.field.value == null || this.field.value == undefined ? this.inputs.push('') : this.inputs.push(this.field.value); this.field.value == null || this.field.value == undefined ? this.inputs.push('') : this.inputs.push(this.field.value);

View File

@ -223,6 +223,15 @@ class Item_Metadata extends Repository {
if ($unique) if ($unique)
$terms = reset($terms); $terms = reset($terms);
if(is_array($terms)){
$terms_array = [];
foreach ($terms as $term){
$terms_array[] = new Entities\Term($term);
}
return $terms_array;
}
return $terms; return $terms;
} elseif ($field_type->get_primitive_type() == 'compound') { } elseif ($field_type->get_primitive_type() == 'compound') {

View File

@ -228,6 +228,8 @@ class Logs extends Repository {
*/ */
public function log_inserts( $new_value, $value = null ) { public function log_inserts( $new_value, $value = null ) {
$msn = ""; $msn = "";
$description = "";
if ( is_object( $new_value ) ) { if ( is_object( $new_value ) ) {
// do not log a log // do not log a log
if ( method_exists( $new_value, 'get_post_type' ) && $new_value->get_post_type() == 'tainacan-log' ) { if ( method_exists( $new_value, 'get_post_type' ) && $new_value->get_post_type() == 'tainacan-log' ) {
@ -235,12 +237,20 @@ class Logs extends Repository {
} }
$type = get_class( $new_value ); $type = get_class( $new_value );
$msn = sprintf( esc_html__( 'a %s has been created/updated.', 'tainacan' ), $type ); $class_name = explode('\\', $type)[2];
$name = method_exists($new_value, 'get_name') ? $new_value->get_name() :
(method_exists($new_value, 'get_title') ? $new_value->get_title() : $new_value->get_field()->get_name());
$msn = sprintf( esc_html__( 'A %s has been created/updated.', 'tainacan' ), $class_name);
$description = sprintf( esc_html__("The '%s' %s has been created/updated.", 'tainacan' ), $name, strtolower($class_name));
} }
$msn = apply_filters( 'tainacan-insert-log-message-title', $msn, $type, $new_value ); $msn = apply_filters( 'tainacan-insert-log-message-title', $msn, $type, $new_value );
$description = apply_filters('tainacan-insert-log-description', $description, $type, $new_value);
return Entities\Log::create( $msn, '', $new_value, $value ); return Entities\Log::create( $msn, $description, $new_value, $value );
} }
/** /**