Fixes enabled of fields and fetch of logs
This commit is contained in:
parent
6e851ed3db
commit
a3a239a435
|
@ -12,25 +12,23 @@ use Tainacan\Entities\Collection;
|
|||
class Collections extends Repository {
|
||||
public $entities_type = '\Tainacan\Entities\Collection';
|
||||
|
||||
private static $instance = null;
|
||||
private static $instance = null;
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
if(!isset(self::$instance))
|
||||
{
|
||||
self::$instance = new self();
|
||||
}
|
||||
public static function getInstance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collections constructor.
|
||||
*/
|
||||
protected function __construct() {
|
||||
parent::__construct();
|
||||
add_filter( 'map_meta_cap', array( $this, 'map_meta_cap' ), 10, 4 );
|
||||
}
|
||||
/**
|
||||
* Collections constructor.
|
||||
*/
|
||||
protected function __construct() {
|
||||
parent::__construct();
|
||||
add_filter( 'map_meta_cap', array( $this, 'map_meta_cap' ), 10, 4 );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@ -138,16 +136,16 @@ class Collections extends Repository {
|
|||
'fields_order' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Ordination fields', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => ['type' => 'array/string/integer/object'],
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'description' => __( 'Collection fields ordination', 'tainacan' ),
|
||||
//'validation' => v::stringType(),
|
||||
],
|
||||
'filters_order' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Ordination filters', 'tainacan' ),
|
||||
'type' => 'array/object/string',
|
||||
'items' => ['type' => 'array/string/integer/object'],
|
||||
'type' => 'array/object/string',
|
||||
'items' => [ 'type' => 'array/string/integer/object' ],
|
||||
'description' => __( 'Collection filters ordination', 'tainacan' ),
|
||||
//'validation' => v::stringType(),
|
||||
],
|
||||
|
|
|
@ -386,11 +386,11 @@ class Fields extends Repository {
|
|||
if( $index !== false ) {
|
||||
|
||||
// skipping fields disabled if the arg is set
|
||||
if( !$include_disabled && isset( $order[$index]['enable'] ) && !$order[$index]['enable'] ) {
|
||||
if( !$include_disabled && isset( $order[$index]['enabled'] ) && !$order[$index]['enabled'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$enable = ( isset( $order[$index]['enable'] )) ? $order[$index]['enable'] : true;
|
||||
$enable = ( isset( $order[$index]['enabled'] )) ? $order[$index]['enabled'] : true;
|
||||
$item->set_enabled_for_collection($enable);
|
||||
|
||||
$result_ordinate[$index] = $item;
|
||||
|
|
|
@ -186,7 +186,7 @@ class Logs extends Repository {
|
|||
|
||||
} elseif ( is_array( $args ) ) {
|
||||
$args = array_merge( [
|
||||
'posts_per_page' => 1,
|
||||
'posts_per_page' => -1,
|
||||
], $args );
|
||||
|
||||
$args = $this->parse_fetch_args( $args );
|
||||
|
@ -210,7 +210,7 @@ class Logs extends Repository {
|
|||
public function fetch_last() {
|
||||
$args = [
|
||||
'post_type' => Entities\Log::get_post_type(),
|
||||
'posts_per_page' => 1,
|
||||
'posts_per_page' => -1,
|
||||
];
|
||||
|
||||
$logs = $this->fetch( $args, 'OBJECT' );
|
||||
|
|
|
@ -36,8 +36,9 @@ class TAINACAN_REST_Logs_Controller extends TAINACAN_UnitApiTestCase {
|
|||
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals('Log 1', $data[1]['title']);
|
||||
$this->assertEquals('Log 2', $data[0]['title']);
|
||||
$log_titles = [$data[1]['title'], $data[0]['title']];
|
||||
$this->assertContains('Log 1', $log_titles);
|
||||
$this->assertContains('Log 2', $log_titles);
|
||||
}
|
||||
|
||||
public function test_get_a_log(){
|
||||
|
|
|
@ -252,9 +252,9 @@ class Fields extends TAINACAN_UnitTestCase {
|
|||
|
||||
$collection->set_fields_order(
|
||||
[
|
||||
array( 'id' => $field3->get_id(), 'enable' => false ),
|
||||
array( 'id' => $field2->get_id(), 'enable' => true ),
|
||||
array( 'id' => $field1->get_id(), 'enable' => true )
|
||||
array( 'id' => $field3->get_id(), 'enabled' => false ),
|
||||
array( 'id' => $field2->get_id(), 'enabled' => true ),
|
||||
array( 'id' => $field1->get_id(), 'enabled' => true )
|
||||
]);
|
||||
|
||||
$update_collection = $Tainacan_Collections->update( $collection );
|
||||
|
|
Loading…
Reference in New Issue