Somes fixes on fetch all field values and fields controller args

This commit is contained in:
weryques 2018-03-15 10:42:43 -03:00
parent bddcb9bf31
commit efa4d5cc7c
3 changed files with 12 additions and 10 deletions

View File

@ -48,7 +48,8 @@ class TAINACAN_REST_Filters_Controller extends TAINACAN_REST_Controller {
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'get_items'),
'permission_callback' => array($this, 'get_items_permissions_check')
'permission_callback' => array($this, 'get_items_permissions_check'),
'args' => $this->get_collection_params()
),
array(
'methods' => WP_REST_Server::CREATABLE,
@ -60,7 +61,8 @@ class TAINACAN_REST_Filters_Controller extends TAINACAN_REST_Controller {
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array($this, 'get_items'),
'permission_callback' => array($this, 'get_items_permissions_check')
'permission_callback' => array($this, 'get_items_permissions_check'),
'args' => $this->get_collection_params()
),
array(
'methods' => WP_REST_Server::CREATABLE,

View File

@ -142,7 +142,7 @@ class Fields extends Repository {
'field_type_options' => [ // not showed in form
'map' => 'meta',
'title' => __('Field Type options', 'tainacan'),
'type' => 'array',
'type' => 'array/object',
'description'=> __('Options specific for field type', 'tainacan'),
'default' => [],
// 'validation' => ''
@ -152,6 +152,7 @@ class Fields extends Repository {
'title' => __('Collection', 'tainacan'),
'type' => 'integer/string',
'description'=> __('The collection ID', 'tainacan'),
'default' => ''
//'validation' => ''
],
'accept_suggestion' => [
@ -663,9 +664,8 @@ class Fields extends Repository {
);
$pre_result = $wpdb->get_results( $sql_string, ARRAY_A );
if (!empty($pre_result)) {
$results[] = $pre_result[0];
$results[] = $pre_result;
}
}
} elseif ( current_user_can( $capabilities->read_private_posts) ) {
@ -694,7 +694,7 @@ class Fields extends Repository {
$pre_result = $wpdb->get_results( $sql_string, ARRAY_A );
if (!empty($pre_result)) {
$results[] = $pre_result[0];
$results[] = $pre_result;
}
}
}

View File

@ -485,7 +485,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
$data1 = $response1->get_data();
$this->assertCount(1, $data1);
$this->assertEquals('12/12/2017', $data1[0]['mvalue']);
$this->assertEquals('12/12/2017', $data1[0][0]['mvalue']);
//=======================
@ -497,7 +497,7 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
$data1 = $response1->get_data();
$this->assertCount(1, $data1);
$this->assertEquals('12/12/2017', $data1[0]['mvalue']);
$this->assertEquals('12/12/2017', $data1[0][0]['mvalue']);
//=======================
@ -509,8 +509,8 @@ class TAINACAN_REST_Metadata_Controller extends TAINACAN_UnitApiTestCase {
$data2 = $response2->get_data();
$this->assertCount(2, $data2);
$this->assertEquals('12/12/2017', $data2[0]['mvalue']);
$this->assertEquals('02/03/2018', $data2[1]['mvalue']);
$this->assertEquals('12/12/2017', $data2[0][0]['mvalue']);
$this->assertEquals('02/03/2018', $data2[1][0]['mvalue']);
}
}