From ad347408501d267abc7497c22b8186043151957e Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Wed, 2 May 2018 21:55:41 -0300 Subject: [PATCH 001/202] begin export xml --- .../class-tainacan-rest-export-controller.php | 197 ++++++++++++++++++ src/api/tainacan-rest-creator.php | 1 + src/exposers/class-tainacan-exposers.php | 6 +- tests/test-api-export.php | 117 +++++++++++ 4 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 src/api/endpoints/class-tainacan-rest-export-controller.php create mode 100644 tests/test-api-export.php diff --git a/src/api/endpoints/class-tainacan-rest-export-controller.php b/src/api/endpoints/class-tainacan-rest-export-controller.php new file mode 100644 index 000000000..6d18844d5 --- /dev/null +++ b/src/api/endpoints/class-tainacan-rest-export-controller.php @@ -0,0 +1,197 @@ +rest_base = 'export'; + parent::__construct(); + add_action('init', array(&$this, 'init_objects'), 11); + } + + /** + * Initialize objects after post_type register + * + * @throws \Exception + */ + public function init_objects() { + $this->field_repository = Repositories\Fields::get_instance(); + $this->item_metadata_repository = Repositories\Item_Metadata::get_instance(); + $this->items_repository = Repositories\Items::get_instance(); + $this->collection_repository = Repositories\Collections::get_instance(); + } + + /** + * If POST on field/collection/, then + * a field will be created in matched collection and all your item will receive this field + * + * If POST on field/item/, then a value will be added in a field and field passed + * id body of requisition + * + * Both of GETs return the field of matched objects + * + * @throws \Exception + */ + public function register_routes() { + register_rest_route($this->namespace, '/' . $this->rest_base. '/collection/(?P[\d]+)', + array( + array( + 'methods' => \WP_REST_Server::READABLE, + 'callback' => array($this, 'get_items'), + 'permission_callback' => array($this, 'get_items_permissions_check'), + 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE), + ), + ) + ); + register_rest_route($this->namespace, '/' . $this->rest_base. '/item/(?P[\d]+)', + array( + array( + 'methods' => \WP_REST_Server::READABLE, + 'callback' => array($this, 'get_item'), + 'permission_callback' => array($this, 'get_item_permissions_check'), + 'args' => $this->get_endpoint_args_for_item_schema(\WP_REST_Server::READABLE), + ), + ) + ); + register_rest_route($this->namespace, '/' . $this->rest_base, + array( + array( + 'methods' => \WP_REST_Server::READABLE, + 'callback' => array($this, 'get_items'), + 'permission_callback' => array($this, 'get_items_permissions_check'), + 'args' => $this->get_collection_params(), + ) + ) + ); + } + + /** + * @param \WP_REST_Request $request + * + * @return \WP_Error|\WP_REST_Response + */ + public function get_item( $request ) { + /*$collection_id = $request['collection_id']; + $field_id = $request['field_id']; + + if($request['fetch'] === 'all_field_values'){ + $results = $this->field_repository->fetch_all_field_values($collection_id, $field_id); + + return new \WP_REST_Response($results, 200); + } + + $result = $this->field_repository->fetch($field_id, 'OBJECT'); + + $prepared_item = $this->prepare_item_for_response($result, $request); + return new \WP_REST_Response(apply_filters('tainacan-rest-response', $prepared_item, $request), 200);*/ + } + + /** + * @param \WP_REST_Request $request + * + * @return bool|\WP_Error + * @throws \Exception + */ + public function get_item_permissions_check( $request ) { + if(isset($request['collection_id'])) { + $collection = $this->collection_repository->fetch($request['collection_id']); + if($collection instanceof Entities\Collection) { + if (! $collection->can_read()) { + return false; + } + return true; + } + } elseif(isset($request['item_id'])) { + $item = $this->items_repository->fetch($request['item_id']); + if($item instanceof Entities\Item) { + if (! $item->can_read()) { + return false; + } + return true; + } + } else { // Exporting all + $dummy = new Entities\Collection(); + return current_user_can($dummy->get_capabilities()->read); // Need to check Colletion by collection + } + return false; + } + + /** + * @param \Tainacan\Entities\Entity $item + * @param \WP_REST_Request $request + * + * @return array|\WP_Error|\WP_REST_Response + */ + public function prepare_item_for_response( $item, $request ) { + $items_metadata = $item->get_fields(); + + $prepared_item = []; + + foreach ($items_metadata as $item_metadata){ + $prepared_item[] = $item_metadata->__toArray(); + } + + return $prepared_item; + } + + /** + * @param \WP_REST_Request $request + * + * @return \WP_Error|\WP_REST_Response + */ + public function get_items( $request ) { + $args = $this->prepare_filters($request); + $rest_response = new \WP_REST_Response([], 200); // TODO error, empty response + + if(isset($request['collection_id'])) { + $collection_id = $request['collection_id']; + $items = $this->items_repository->fetch($args, $collection_id, 'WP_Query'); + + $response = []; + if ($items->have_posts()) { + while ( $items->have_posts() ) { + $items->the_post(); + + $item = new Entities\Item($items->post); + + $prepared_item = $this->prepare_item_for_response($item, $request); + + array_push($response, $prepared_item); + } + + wp_reset_postdata(); + } + + $total_items = $items->found_posts; + $max_pages = ceil($total_items / (int) $items->query_vars['posts_per_page']); + + $rest_response = new \WP_REST_Response(apply_filters('tainacan-rest-response', $response, $request), 200); + + $rest_response->header('X-WP-Total', (int) $total_items); + $rest_response->header('X-WP-TotalPages', (int) $max_pages); + } + return $rest_response; + } + + /** + * @param \WP_REST_Request $request + * + * @return bool|\WP_Error + * @throws \Exception + */ + public function get_items_permissions_check( $request ) { + return $this->get_item_permissions_check($request); + } + +} + +?> \ No newline at end of file diff --git a/src/api/tainacan-rest-creator.php b/src/api/tainacan-rest-creator.php index 45c1a18f0..fb0240d5e 100644 --- a/src/api/tainacan-rest-creator.php +++ b/src/api/tainacan-rest-creator.php @@ -13,6 +13,7 @@ $rest_item_metadata_controller = new \Tainacan\API\EndPoints\REST_Item_Metadata_ $rest_logs_controller = new \Tainacan\API\EndPoints\REST_Logs_Controller(); $rest_field_types_controller = new \Tainacan\API\EndPoints\REST_Field_Types_Controller(); $rest_filter_types_controller = new \Tainacan\API\EndPoints\REST_Filter_Types_Controller(); +new \Tainacan\API\EndPoints\REST_Export_Controller(); // Add here other endpoints imports ?> \ No newline at end of file diff --git a/src/exposers/class-tainacan-exposers.php b/src/exposers/class-tainacan-exposers.php index 8dbe3f406..74cf66cac 100644 --- a/src/exposers/class-tainacan-exposers.php +++ b/src/exposers/class-tainacan-exposers.php @@ -142,7 +142,11 @@ class Exposers { } else { // array of elements $ret = []; foreach ($item_arr as $item) { - $ret = array_merge($ret, $this->map($item, $mapper, $resquest) ); + if(array_key_exists('field', $item)) { + $ret = array_merge($ret, $this->map($item, $mapper, $resquest) ); + } else { + $ret[] = $this->map($item, $mapper, $resquest); + } } } return $ret; diff --git a/tests/test-api-export.php b/tests/test-api-export.php new file mode 100644 index 000000000..59041e9b1 --- /dev/null +++ b/tests/test-api-export.php @@ -0,0 +1,117 @@ +tainacan_entity_factory->create_entity( + 'collection', + array( + 'name' => 'testeItemExport', + 'description' => 'No description', + ), + true, + true + ); + + $type = $this->tainacan_field_factory->create_field('text'); + + $field = $this->tainacan_entity_factory->create_entity( + 'field', + array( + 'name' => 'teste_Export', + 'description' => 'descricao', + 'collection' => $collection, + 'field_type' => $type, + 'exposer_mapping' => [ + 'dublin-core' => 'language' + ] + ), + true, + true + ); + + $item = $this->tainacan_entity_factory->create_entity( + 'item', + array( + 'title' => 'item_teste_Export', + 'description' => 'adasdasdsa', + 'collection' => $collection + ), + true, + true + ); + + $Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance(); + + $item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($item, $field); + + $item_metadata->set_value('teste_export_field_value'); + + $item_metadata->validate(); + + $item_metadata = $Tainacan_Item_Metadata->insert($item_metadata); + + $item2 = $this->tainacan_entity_factory->create_entity( + 'item', + array( + 'title' => 'item_teste_Export2', + 'description' => 'adasdasdsa2', + 'collection' => $collection + ), + true, + true + ); + + $item_metadata2 = new \Tainacan\Entities\Item_Metadata_Entity($item2, $field); + + $item_metadata2->set_value('teste_export_field_value2'); + + $item_metadata2->validate(); + + $item_metadata2 = $Tainacan_Item_Metadata->insert($item_metadata2); + + $item3 = $this->tainacan_entity_factory->create_entity( + 'item', + array( + 'title' => 'item_teste_Export3', + 'description' => 'adasdasdsa3', + 'collection' => $collection + ), + true, + true + ); + + $item_metadata3 = new \Tainacan\Entities\Item_Metadata_Entity($item3, $field); + + $item_metadata3->set_value('teste_export_field_value3'); + + $item_metadata3->validate(); + + $item_metadata3 = $Tainacan_Item_Metadata->insert($item_metadata3); + + return ['collection' => $collection, 'items' => [$item, $item2, $item3], 'field' => $field, 'items_metadatas' => [$item_metadata, $item_metadata2, $item_metadata3]]; + } + + public function test_export_a_collection() { + extract($this->create_requirements()); + + $item_exposer_json = json_encode([ + 'exposer-type' => 'Xml', + 'exposer-map' => 'Value', + ]); + + $request = new \WP_REST_Request('GET', $this->namespace . '/export/collection/' . $collection->get_id() ); + $request->set_body($item_exposer_json); + $response = $this->server->dispatch($request); + $this->assertEquals(200, $response->get_status()); + $data = $response->get_data(); + print_r($data); + } +} + +?> \ No newline at end of file From d420e815837d5228936a429e25d3ab8127727891 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Tue, 15 May 2018 18:23:24 -0300 Subject: [PATCH 002/202] add export api --- .../class-tainacan-rest-export-controller.php | 157 +++++++++++++++--- 1 file changed, 136 insertions(+), 21 deletions(-) diff --git a/src/api/endpoints/class-tainacan-rest-export-controller.php b/src/api/endpoints/class-tainacan-rest-export-controller.php index 6d18844d5..0a2b760a4 100644 --- a/src/api/endpoints/class-tainacan-rest-export-controller.php +++ b/src/api/endpoints/class-tainacan-rest-export-controller.php @@ -5,6 +5,7 @@ namespace Tainacan\API\EndPoints; use \Tainacan\API\REST_Controller; use Tainacan\Entities; use Tainacan\Repositories; +use Tainacan\Entities\Entity; class REST_Export_Controller extends REST_Controller { private $item_metadata_repository; @@ -126,7 +127,7 @@ class REST_Export_Controller extends REST_Controller { } /** - * @param \Tainacan\Entities\Entity $item + * @param \Tainacan\Entities\Item $item * @param \WP_REST_Request $request * * @return array|\WP_Error|\WP_REST_Response @@ -142,6 +143,118 @@ class REST_Export_Controller extends REST_Controller { return $prepared_item; } + + /** + * + * @param \WP_REST_Request $request + * @param \WP_Query|Entities\Item $query + * @param array $args + * @return \WP_Error|number + */ + public function export($request, $query, $args) { + + $type = \Tainacan\Exposers\Exposers::request_has_type($request); + $path = wp_upload_dir(); + $path = $path['path']; + $filename = $path.date('YmdHis').'-tainacan-export.'.$type->get_extension(); + $pid = -1; + + $log = \Tainacan\Entities\Log::create( + __('Export Process', 'tainacan'), + __('Exporting Data', 'tainacan').'\nArgs: '.print_r($args, true), + ['file' => $filename], + [], + 'processing' + ); + + $body = json_decode( $request->get_body(), true ); + $background = ! (isset($body['export-background']) && $body['export-background'] == false); + if( $background ) { + $pid = pcntl_fork(); + } else { + $pid = true; + } + if ($pid === -1) { + $error = new \WP_Error('could not fork'); + $log = \Tainacan\Entities\Log::create( + __('Export Process Error', 'tainacan'), + __('Exporting Error', 'tainacan').'\\nArgs: '.print_r($args, true).'\\nError: could not fork', + $error, + [], + 'error' + ); + remove_filter( 'rest_request_after_callbacks', [\Tainacan\Exposers\Exposers::get_instance(), 'rest_request_after_callbacks'], 10, 3 ); //exposer mapping + remove_filter( 'tainacan-rest-response', [\Tainacan\Exposers\Exposers::get_instance(), 'rest_response'], 10, 2 ); // exposer types + return $log; + } elseif ($pid) { // we are the parent or run at foreground + try { + ignore_user_abort(true); + set_time_limit(0); + ini_set("memory_limit", "256M"); + + if($background) { // wait for child to respond and exit and reconnect database if is forked + $status = null; + pcntl_wait($status); + global $wpdb; + $wpdb->db_connect(); + } + + $response = []; + if(isset($request['collection_id'])) { // One Colletion + $collection_id = $request['collection_id']; + $items = $query; + if ($items->have_posts()) { + while ( $items->have_posts() ) { //TODO write line by line + $items->the_post(); + + $item = new Entities\Item($items->post); + + $prepared_item = $this->prepare_item_for_response($item, $request); + + array_push($response, $prepared_item); + file_put_contents('/tmp/2', print_r($prepared_item, true), FILE_APPEND); + } + wp_reset_postdata(); + } + } elseif (isset($request['item_id'])) { // One Item + + $item = new Entities\Item($request['item_id']); + if($item->get_id() > 0) { + $prepared_item = $this->prepare_item_for_response($item, $request); + + $response = [$prepared_item]; + } + } else { // Export All + + } + + $rest_response = new \WP_REST_Response(apply_filters('tainacan-rest-response', $response, $request)); + //file_put_contents($filename, $rest_response->get_data()); + file_put_contents('/tmp/1', print_r($rest_response->get_data(), true)); + + if($background) { + $log->set_status('publish'); + $logs = \Tainacan\Repositories\Logs::get_instance(); + $logs->update($log); + exit(1); + } else { + return $rest_response->get_data(); + } + } catch (\Exception $e) { + if($background) { + exit(1); + } else { + throw $e; + } + } + } else { // we are the child + + remove_filter( 'rest_request_after_callbacks', [\Tainacan\Exposers\Exposers::get_instance(), 'rest_request_after_callbacks'], 10, 3 ); //exposer mapping + remove_filter( 'tainacan-rest-response', [\Tainacan\Exposers\Exposers::get_instance(), 'rest_response'], 10, 2 ); // exposer types + return $log; + } + + } /** * @param \WP_REST_Request $request @@ -149,36 +262,38 @@ class REST_Export_Controller extends REST_Controller { * @return \WP_Error|\WP_REST_Response */ public function get_items( $request ) { - $args = $this->prepare_filters($request); + $args = $this->prepare_filters($request); // TODO default args $rest_response = new \WP_REST_Response([], 200); // TODO error, empty response - if(isset($request['collection_id'])) { + if(isset($request['collection_id'])) { // One Colletion $collection_id = $request['collection_id']; $items = $this->items_repository->fetch($args, $collection_id, 'WP_Query'); - $response = []; - if ($items->have_posts()) { - while ( $items->have_posts() ) { - $items->the_post(); - - $item = new Entities\Item($items->post); - - $prepared_item = $this->prepare_item_for_response($item, $request); - - array_push($response, $prepared_item); - } - - wp_reset_postdata(); - } + $response = $this->export($request, $items, $args); $total_items = $items->found_posts; - $max_pages = ceil($total_items / (int) $items->query_vars['posts_per_page']); - - $rest_response = new \WP_REST_Response(apply_filters('tainacan-rest-response', $response, $request), 200); + $ret = $response instanceof Entity ? $response->__toArray() : $response; + $rest_response = new \WP_REST_Response($ret, 200); $rest_response->header('X-WP-Total', (int) $total_items); - $rest_response->header('X-WP-TotalPages', (int) $max_pages); + } elseif (isset($request['item_id'])) { // One Item + + $item = new Entities\Item($request['item_id']); + if($item->get_id() > 0) { + $response = $this->export($request, $item, $args); + + $total_items = 1; + $max_pages = 1; + + $rest_response = new \WP_REST_Response($response->__toArray(), 200); + + $rest_response->header('X-WP-Total', 1); + $rest_response->header('X-WP-TotalPages', 1); + } + } else { // Export All + } + return $rest_response; } From b74be3cdc4468b0407756728be193ae0e558dce5 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Tue, 15 May 2018 18:23:49 -0300 Subject: [PATCH 003/202] add suport to parent log --- src/classes/entities/class-tainacan-log.php | 6 ++++-- src/classes/repositories/class-tainacan-logs.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/classes/entities/class-tainacan-log.php b/src/classes/entities/class-tainacan-log.php index ad95c2254..812216e37 100644 --- a/src/classes/entities/class-tainacan-log.php +++ b/src/classes/entities/class-tainacan-log.php @@ -257,18 +257,20 @@ class Log extends Entity { * @param string $desc * @param mixed $new_value * @param array $diffs - * @param string $status 'publish', 'private' or 'pending' + * @param string $status 'publish', 'private', 'pending', 'processing' or 'error' + * @param int $parent * * @return \Tainacan\Entities\Log * @throws \Exception */ - public static function create( $msn = false, $desc = '', $new_value = null, $diffs = [], $status = 'publish' ) { + public static function create( $msn = false, $desc = '', $new_value = null, $diffs = [], $status = 'publish', $parent = 0 ) { $log = new Log(); $log->set_title( $msn ); $log->set_description( $desc ); $log->set_status( $status ); $log->set_log_diffs( $diffs ); + if($parent > 0) $log->set_parent($parent); if ( ! is_null( $new_value ) ) { $log->set_value( $new_value ); diff --git a/src/classes/repositories/class-tainacan-logs.php b/src/classes/repositories/class-tainacan-logs.php index a84564b1a..5d2727ae7 100644 --- a/src/classes/repositories/class-tainacan-logs.php +++ b/src/classes/repositories/class-tainacan-logs.php @@ -206,7 +206,7 @@ class Logs extends Repository { } public function update( $object, $new_values = null ) { - + return $this->insert($object); } public function fetch_last() { From 3058014b494b5cd2683e3c7b6829605c01234649 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Tue, 15 May 2018 18:25:50 -0300 Subject: [PATCH 004/202] fix function doc --- src/exposers/class-tainacan-exposers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exposers/class-tainacan-exposers.php b/src/exposers/class-tainacan-exposers.php index 953fd00d4..4771edbc4 100644 --- a/src/exposers/class-tainacan-exposers.php +++ b/src/exposers/class-tainacan-exposers.php @@ -178,7 +178,7 @@ class Exposers { return in_array($this->check_class_name($type), $this->types); } /** - * Return Type with request has type, false otherwise + * Return Type if request has type, false otherwise * @param \WP_REST_Request $request * @return Types\Type|boolean false */ From fc91167c6c488d3c470372f6f5e0e581b9055ec2 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Tue, 15 May 2018 18:28:43 -0300 Subject: [PATCH 005/202] add support to file extension on exports and exposers --- src/exposers/types/class-tainacan-type.php | 8 ++++++++ src/exposers/types/class-tainacan-xml.php | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/exposers/types/class-tainacan-type.php b/src/exposers/types/class-tainacan-type.php index b5902c7f5..967f59a1d 100644 --- a/src/exposers/types/class-tainacan-type.php +++ b/src/exposers/types/class-tainacan-type.php @@ -9,6 +9,7 @@ namespace Tainacan\Exposers\Types; abstract class Type { protected $mappers = true; // List of supported mapper, leave true for all + protected $extension = 'tnc'; // extension sufix for multi operation system compatibility /** * Change response after api callbacks @@ -19,7 +20,14 @@ abstract class Type { */ public abstract function rest_request_after_callbacks( $response, $handler, $request ); + /** + * Return list of supported mappers for this type + */ public function get_mappers() { return apply_filters('tainacan-exporser-type-mappers', $this->mappers, $this); } + + public function get_extension() { + return $this->extension; + } } \ No newline at end of file diff --git a/src/exposers/types/class-tainacan-xml.php b/src/exposers/types/class-tainacan-xml.php index 24ffe1ea9..9943a76cd 100644 --- a/src/exposers/types/class-tainacan-xml.php +++ b/src/exposers/types/class-tainacan-xml.php @@ -7,6 +7,13 @@ namespace Tainacan\Exposers\Types; * */ class Xml extends Type { + /** + * {@inheritdoc} + * @see \Tainacan\Exposers\Types\Type::extension + * @var string + */ + protected $extension = 'xml'; + /** * * {@inheritDoc} From d50ff6b9591570499d11ff693af6e0e761a1bbec Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Tue, 15 May 2018 18:29:17 -0300 Subject: [PATCH 006/202] add export simple test, only for foreground export --- tests/test-api-export.php | 58 ++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/tests/test-api-export.php b/tests/test-api-export.php index 59041e9b1..e37eb32a8 100644 --- a/tests/test-api-export.php +++ b/tests/test-api-export.php @@ -57,15 +57,15 @@ class TAINACAN_REST_Export_Controller extends TAINACAN_UnitApiTestCase { $item_metadata = $Tainacan_Item_Metadata->insert($item_metadata); $item2 = $this->tainacan_entity_factory->create_entity( - 'item', - array( - 'title' => 'item_teste_Export2', - 'description' => 'adasdasdsa2', - 'collection' => $collection - ), - true, - true - ); + 'item', + array( + 'title' => 'item_teste_Export2', + 'description' => 'adasdasdsa2', + 'collection' => $collection + ), + true, + true + ); $item_metadata2 = new \Tainacan\Entities\Item_Metadata_Entity($item2, $field); @@ -76,15 +76,15 @@ class TAINACAN_REST_Export_Controller extends TAINACAN_UnitApiTestCase { $item_metadata2 = $Tainacan_Item_Metadata->insert($item_metadata2); $item3 = $this->tainacan_entity_factory->create_entity( - 'item', - array( - 'title' => 'item_teste_Export3', - 'description' => 'adasdasdsa3', - 'collection' => $collection - ), - true, - true - ); + 'item', + array( + 'title' => 'item_teste_Export3', + 'description' => 'adasdasdsa3', + 'collection' => $collection + ), + true, + true + ); $item_metadata3 = new \Tainacan\Entities\Item_Metadata_Entity($item3, $field); @@ -103,14 +103,34 @@ class TAINACAN_REST_Export_Controller extends TAINACAN_UnitApiTestCase { $item_exposer_json = json_encode([ 'exposer-type' => 'Xml', 'exposer-map' => 'Value', + 'export-background' => false ]); + $query = [ + 'orderby' => 'id', + 'order' => 'asc', + ]; + $request = new \WP_REST_Request('GET', $this->namespace . '/export/collection/' . $collection->get_id() ); + $request->set_query_params($query); $request->set_body($item_exposer_json); $response = $this->server->dispatch($request); $this->assertEquals(200, $response->get_status()); $data = $response->get_data(); - print_r($data); + + $this->assertInstanceOf('SimpleXMLElement', $xml = @simplexml_load_string($data)); + + $this->assertEquals(3, $xml->count()); + $i = 0; + foreach ($xml->children() as $xml_item ) { + $fields = $items[$i]->get_fields(); + foreach ($fields as $field_meta) { + $field = $field_meta->get_field(); + $this->assertEquals($field_meta->get_value(), $xml_item->{$field->get_name()}); + //echo "{$field->get_name()}:{$field_meta->get_value()}"; // uncomment if need debug + } + $i++; + } } } From af796bb01b6a565492a0230d11b584203493b810 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Tue, 15 May 2018 18:47:58 -0300 Subject: [PATCH 007/202] fix log string error --- src/classes/entities/class-tainacan-log.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/classes/entities/class-tainacan-log.php b/src/classes/entities/class-tainacan-log.php index 6786e2180..43179ddd0 100644 --- a/src/classes/entities/class-tainacan-log.php +++ b/src/classes/entities/class-tainacan-log.php @@ -288,10 +288,12 @@ class Log extends Entity { $log->set_log_diffs( $diffs ); if($parent > 0) $log->set_parent($parent); - if(array_search( 'Tainacan\Traits\Entity_Collection_Relation', class_uses($new_value))) { - $log->set_collection_id( $new_value->get_collection_id() ); - } elseif($new_value instanceof Collection){ - $log->set_collection_id( $new_value->get_id()); + if(is_object($new_value) || is_string($new_value)) { + if(array_search( 'Tainacan\Traits\Entity_Collection_Relation', class_uses($new_value))) { + $log->set_collection_id( $new_value->get_collection_id() ); + } elseif($new_value instanceof Collection){ + $log->set_collection_id( $new_value->get_id()); + } } if ( ! is_null( $new_value ) ) { From e7b8388f87dbe24c96e3d49df480ab973841aeb5 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 17 May 2018 12:25:58 -0300 Subject: [PATCH 008/202] begin to add support to new mapped collection --- .../edition/collection-edition-form.vue | 9 +++++++ src/admin/js/router.js | 1 + src/admin/js/utilities.js | 3 +++ src/admin/pages/lists/collections-page.vue | 27 +++++++++++++++++++ src/admin/tainacan-admin-i18n.php | 5 ++-- src/exposers/class-tainacan-exposers.php | 9 +++++++ 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/admin/components/edition/collection-edition-form.vue b/src/admin/components/edition/collection-edition-form.vue index 54920f759..3b333078e 100644 --- a/src/admin/components/edition/collection-edition-form.vue +++ b/src/admin/components/edition/collection-edition-form.vue @@ -350,6 +350,7 @@ export default { editFormErrors: {}, formErrorMessage: '', isNewCollection: false, + isMapped: false, thumbPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_square.png', headerPlaceholderPath: tainacan_plugin.base_url + '/admin/images/placeholder_rectangle.png', isFetchingModerators: false, @@ -636,6 +637,14 @@ export default { this.isLoading = false; }); + } else { + var tmppath = this.$route.fullPath.split("/"); + var mapper = tmppath.pop(); + if(tmppath.pop() == 'new') { + this.isNewCollection = true; + this.isMapped = mapper; + this.createNewCollection(); + } } } diff --git a/src/admin/js/router.js b/src/admin/js/router.js index 82f8c8bdf..768a86510 100644 --- a/src/admin/js/router.js +++ b/src/admin/js/router.js @@ -35,6 +35,7 @@ const routes = [ { path: '/collections', name: 'CollectionsPage', component: CollectionsPage, meta: {title: i18nGet('title_repository_collections_page'), icon: 'folder-multiple'} }, { path: '/collections/new', name: 'CollectionCreationForm', component: CollectionEditionForm, meta: {title: i18nGet('title_create_collection'), icon: 'folder-multiple'} }, + { path: '/collections/new/:mapper', name: 'MappedCollectionCreationForm', component: CollectionEditionForm, meta: {title: i18nGet('title_create_collection'), icon: 'folder-multiple'} }, { path: '/collections/:collectionId', component: CollectionPage, meta: {title: i18nGet('title_collection_page'), icon: 'folder-multiple'}, children: [ diff --git a/src/admin/js/utilities.js b/src/admin/js/utilities.js index 9536e1a3b..6f031fb5e 100644 --- a/src/admin/js/utilities.js +++ b/src/admin/js/utilities.js @@ -212,6 +212,9 @@ RouterHelperPlugin.install = function (Vue, options = {}) { getNewCollectionPath() { return '/collections/new'; }, + getNewMappedCollectionPath(mapperSlug) { + return '/collections/new/' + mapperSlug; + }, getNewItemPath(collectionId) { return '/collections/' + collectionId + '/items/new'; }, diff --git a/src/admin/pages/lists/collections-page.vue b/src/admin/pages/lists/collections-page.vue index ee5458364..93d415f3f 100644 --- a/src/admin/pages/lists/collections-page.vue +++ b/src/admin/pages/lists/collections-page.vue @@ -12,6 +12,33 @@ :to="{ path: $routerHelper.getNewCollectionPath() }"> {{ $i18n.getFrom('collections', 'new_item') }} + + + + + {{ $i18n.getFrom('collections', 'new_item') }} + + + + + {{ $i18n.get('new_mapped_item') }} + + +
diff --git a/src/admin/tainacan-admin-i18n.php b/src/admin/tainacan-admin-i18n.php index 7dec29684..8df375376 100644 --- a/src/admin/tainacan-admin-i18n.php +++ b/src/admin/tainacan-admin-i18n.php @@ -1,6 +1,6 @@ __( 'Repository', 'tainacan' ), 'collections' => __( 'Collections', 'tainacan' ), @@ -39,6 +39,7 @@ return [ 'add_one_item' => __( 'Add one item', 'tainacan' ), 'add_items_bulk' => __( 'Add items in bulk', 'tainacan' ), 'add_items_external_source' => __( 'Add items from an external source', 'tainacan' ), + 'new_mapped_item' => __( 'New mapped collection', 'tainacan' ), // Wordpress Status 'publish' => __( 'Publish', 'tainacan' ), @@ -271,5 +272,5 @@ return [ 'tainacan-filter-category-taginput' => __( 'Category Tag Input', 'tainacan' ), 'tainacan-filter-category-checkbox' => __( 'Category Check Box', 'tainacan' ), 'tainacan-filter-category-selectbox' => __( 'Category Select Box', 'tainacan' ) -] +]); ?> diff --git a/src/exposers/class-tainacan-exposers.php b/src/exposers/class-tainacan-exposers.php index 4771edbc4..6632cf510 100644 --- a/src/exposers/class-tainacan-exposers.php +++ b/src/exposers/class-tainacan-exposers.php @@ -37,6 +37,7 @@ class Exposers { add_filter( 'rest_request_after_callbacks', [$this, 'rest_request_after_callbacks'], 10, 3 ); //exposer mapping add_filter( 'tainacan-rest-response', [$this, 'rest_response'], 10, 2 ); // exposer types + add_filter( 'tainacan-js-i18n', [$this, 'mappers_i18n']); } /** @@ -231,4 +232,12 @@ class Exposers { } return false; // No mapper need, using Tainacan defautls } + + public function mappers_i18n($i18n_strings) { + foreach ($this->mappers as $mapper) { + $obj = new $mapper; + $i18n_strings[$obj->slug] = $obj->slug; + } + return $i18n_strings; + } } \ No newline at end of file From bacd2cd4b55156c85b2d4fac63de95d684e1b5af Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Fri, 18 May 2018 16:33:37 -0300 Subject: [PATCH 009/202] Mateus corrections --- src/admin/pages/lists/collections-page.vue | 49 ++++++++++------------ 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/src/admin/pages/lists/collections-page.vue b/src/admin/pages/lists/collections-page.vue index 93d415f3f..4cf7dc068 100644 --- a/src/admin/pages/lists/collections-page.vue +++ b/src/admin/pages/lists/collections-page.vue @@ -5,36 +5,31 @@ class="sub-header" v-if="totalCollections > 0">
- - {{ $i18n.getFrom('collections', 'new_item') }} - - - - - + + + + {{ $i18n.getFrom('collections', 'new_item') }} - - + + {{ $i18n.get('new_mapped_item') }} From fd08babd046d5ae47a4d4c7075b37862e65e1b6d Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Wed, 23 May 2018 15:06:29 -0300 Subject: [PATCH 010/202] add api list of mappers --- ...tainacan-rest-field-mappers-controller.php | 70 +++++++++++++++++++ src/api/tainacan-rest-creator.php | 1 + src/exposers/class-tainacan-exposers.php | 20 ++++++ .../mappers/class-tainacan-mapper.php | 13 ++++ tests/test-api-field-mappers.php | 37 ++++++++++ 5 files changed, 141 insertions(+) create mode 100644 src/api/endpoints/class-tainacan-rest-field-mappers-controller.php create mode 100644 tests/test-api-field-mappers.php diff --git a/src/api/endpoints/class-tainacan-rest-field-mappers-controller.php b/src/api/endpoints/class-tainacan-rest-field-mappers-controller.php new file mode 100644 index 000000000..cbf3c8076 --- /dev/null +++ b/src/api/endpoints/class-tainacan-rest-field-mappers-controller.php @@ -0,0 +1,70 @@ +rest_base = 'field-mappers'; + parent::__construct(); + } + + public function register_routes() { + register_rest_route($this->namespace, '/' . $this->rest_base, + array( + array( + 'methods' => \WP_REST_Server::READABLE, + 'callback' => array($this, 'get_items'), + 'permission_callback' => array($this, 'get_items_permissions_check'), + ) + ) + ); + } + + /** + * @param \Tainacan\Exposers\Mappers\Mapper $mapper + * @param \WP_REST_Request $request + *map + * @return mixed|\WP_Error|\WP_REST_Response + */ + public function prepare_item_for_response( $mapper, $request ) { + + $field_arr = $mapper->_toArray(); + + return $field_arr; + } + + /** + * @param \WP_REST_Request $request + * + * @return \WP_Error|\WP_REST_Response + */ + public function get_items( $request ) { + $Tainacan_Exposers = \Tainacan\Exposers\Exposers::get_instance(); + + $field_mappers = $Tainacan_Exposers->get_mappers( 'OBJECT' ); + + $prepared = []; + foreach ($field_mappers as $field_mapper){ + array_push($prepared, $this->prepare_item_for_response($field_mapper, $request)); + } + + return new \WP_REST_Response($prepared, 200); + } + + /** + * @param \WP_REST_Request $request + * + * @return bool|\WP_Error + */ + public function get_items_permissions_check( $request ) { + return true; + } +} + +?> \ No newline at end of file diff --git a/src/api/tainacan-rest-creator.php b/src/api/tainacan-rest-creator.php index fb0240d5e..f69cb3583 100644 --- a/src/api/tainacan-rest-creator.php +++ b/src/api/tainacan-rest-creator.php @@ -14,6 +14,7 @@ $rest_logs_controller = new \Tainacan\API\EndPoints\REST_Logs_Controlle $rest_field_types_controller = new \Tainacan\API\EndPoints\REST_Field_Types_Controller(); $rest_filter_types_controller = new \Tainacan\API\EndPoints\REST_Filter_Types_Controller(); new \Tainacan\API\EndPoints\REST_Export_Controller(); +new \Tainacan\API\EndPoints\REST_Field_Mappers_Controller(); // Add here other endpoints imports ?> \ No newline at end of file diff --git a/src/exposers/class-tainacan-exposers.php b/src/exposers/class-tainacan-exposers.php index 6632cf510..403b39ff1 100644 --- a/src/exposers/class-tainacan-exposers.php +++ b/src/exposers/class-tainacan-exposers.php @@ -240,4 +240,24 @@ class Exposers { } return $i18n_strings; } + + /** + * Return list of registered mappers + * @param string $output output format, ARRAY_N or OBJECT + */ + public function get_mappers($output = ARRAY_N) { + $ret = []; + switch ($output) { + case OBJECT: + foreach ($this->mappers as $mapper) { + $ret[] = new $mapper; + } + break; + case ARRAY_N: + default: + return $this->mappers; + break; + } + return $ret; + } } \ No newline at end of file diff --git a/src/exposers/mappers/class-tainacan-mapper.php b/src/exposers/mappers/class-tainacan-mapper.php index 5db2ef90e..87ada2fd1 100644 --- a/src/exposers/mappers/class-tainacan-mapper.php +++ b/src/exposers/mappers/class-tainacan-mapper.php @@ -11,4 +11,17 @@ abstract class Mapper { public $prefix = ''; // Tag prefix like "dc:" public $sufix = ''; // Tag sufix public $header = false; // API response header or file header to be used with + + public function _toArray() { + return [ + 'slug' => $this->slug, + 'name' => $this->name, + 'allow_extra_fields' => $this->allow_extra_fields, + 'context_url' => $this->context_url, + 'metadata' => $this->metadata, + 'prefix' => $this->prefix, + 'sufix' => $this->sufix, + 'header' => $this->header + ]; + } } \ No newline at end of file diff --git a/tests/test-api-field-mappers.php b/tests/test-api-field-mappers.php new file mode 100644 index 000000000..27ed67f04 --- /dev/null +++ b/tests/test-api-field-mappers.php @@ -0,0 +1,37 @@ +namespace . '/field-mappers'); + + $field_mapper_response = $this->server->dispatch($field_mapper_request); + + $data = $field_mapper_response->get_data(); + + $Tainacan_Fields = \Tainacan\Exposers\Exposers::get_instance(); + + $field_mappers = $Tainacan_Fields->get_mappers("OBJECT"); + + $this->assertEquals(count($field_mappers), count($data)); + + for ($i = 0; $i < count($data); $i++) { + $this->assertEquals($field_mappers[$i]->slug, $data[$i]['slug']); + $this->assertEquals($field_mappers[$i]->name, $data[$i]['name']); + $this->assertEquals($field_mappers[$i]->allow_extra_fields, $data[$i]['allow_extra_fields']); + $this->assertEquals($field_mappers[$i]->context_url, $data[$i]['context_url']); + $this->assertEquals($field_mappers[$i]->metadata, $data[$i]['metadata']); + $this->assertEquals($field_mappers[$i]->prefix, $data[$i]['prefix']); + $this->assertEquals($field_mappers[$i]->sufix, $data[$i]['sufix']); + $this->assertEquals($field_mappers[$i]->header, $data[$i]['header']); + } + } +} + +?> \ No newline at end of file From 800a91942f87cfb3681ee301d8588f39b7ed0980 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 24 May 2018 11:49:38 -0300 Subject: [PATCH 011/202] add get mappers to vuex --- src/js/store/modules/fields/actions.js | 20 +++++++++++++++++++- src/js/store/modules/fields/getters.js | 4 ++++ src/js/store/modules/fields/index.js | 1 + src/js/store/modules/fields/mutations.js | 4 ++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/js/store/modules/fields/actions.js b/src/js/store/modules/fields/actions.js index 5df4c5dd3..fffbbe909 100644 --- a/src/js/store/modules/fields/actions.js +++ b/src/js/store/modules/fields/actions.js @@ -126,7 +126,25 @@ export const fetchFieldTypes = ({commit}) => { }); } - export const updateFieldTypes = ({commit}, fieldTypes) => { commit('setFieldTypes', fieldTypes); }; + +export const fetchFieldMappers = ({commit}) => { + return new Promise((resolve, reject) => { + axios.tainacan.get('/field-mappers') + .then((res) => { + let fieldMappers = res.data; + commit('setFieldMappers', fieldMappers); + resolve(fieldMappers); + }) + .catch((error) => { + console.log(error); + reject(error); + }); + }); +} + +export const updateFieldMappers = ({commit}, fieldMappers) => { + commit('setFieldMappers', fieldMappers); +}; diff --git a/src/js/store/modules/fields/getters.js b/src/js/store/modules/fields/getters.js index 82abde986..e097e2b6a 100644 --- a/src/js/store/modules/fields/getters.js +++ b/src/js/store/modules/fields/getters.js @@ -5,4 +5,8 @@ export const getFields = state => { export const getFieldTypes = state => { return state.fieldTypes; +} + +export const getFieldMappers = state => { + return state.fieldMappers; } \ No newline at end of file diff --git a/src/js/store/modules/fields/index.js b/src/js/store/modules/fields/index.js index 97905afdf..8e4294fc3 100644 --- a/src/js/store/modules/fields/index.js +++ b/src/js/store/modules/fields/index.js @@ -5,6 +5,7 @@ import * as mutations from './mutations'; const state = { fields: [], fieldTypes: [], + fieldMappers: [], }; export default { diff --git a/src/js/store/modules/fields/mutations.js b/src/js/store/modules/fields/mutations.js index ef3764140..9548fdf99 100644 --- a/src/js/store/modules/fields/mutations.js +++ b/src/js/store/modules/fields/mutations.js @@ -18,3 +18,7 @@ export const setFields = (state, fields) => { export const setFieldTypes = (state, fieldTypes) => { state.fieldTypes = fieldTypes; } + +export const setFieldMappers = (state, fieldMappers) => { + state.fieldMappers = fieldMappers; +} From 0142511a1051f465aefed258cbb14d2932143d89 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 24 May 2018 11:50:32 -0300 Subject: [PATCH 012/202] add support to i18n to mappers props --- src/exposers/class-tainacan-exposers.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/exposers/class-tainacan-exposers.php b/src/exposers/class-tainacan-exposers.php index 403b39ff1..836201468 100644 --- a/src/exposers/class-tainacan-exposers.php +++ b/src/exposers/class-tainacan-exposers.php @@ -37,7 +37,7 @@ class Exposers { add_filter( 'rest_request_after_callbacks', [$this, 'rest_request_after_callbacks'], 10, 3 ); //exposer mapping add_filter( 'tainacan-rest-response', [$this, 'rest_response'], 10, 2 ); // exposer types - add_filter( 'tainacan-js-i18n', [$this, 'mappers_i18n']); + add_filter( 'tainacan-admin-i18n', [$this, 'mappers_i18n']); } /** @@ -233,10 +233,16 @@ class Exposers { return false; // No mapper need, using Tainacan defautls } + /** + * Add mappers data to translations + * @param array $i18n_strings + * @return array + */ public function mappers_i18n($i18n_strings) { foreach ($this->mappers as $mapper) { $obj = new $mapper; - $i18n_strings[$obj->slug] = $obj->slug; + $i18n_strings[$obj->slug] = $obj->slug; // For url breadcrumb translations + $i18n_strings[$obj->name] = $obj->name; } return $i18n_strings; } From 71e8ff5480147454f507076818905b1fb5eda793 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 24 May 2018 11:51:10 -0300 Subject: [PATCH 013/202] add blank collection string to i18n --- src/admin/tainacan-admin-i18n.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/admin/tainacan-admin-i18n.php b/src/admin/tainacan-admin-i18n.php index 8df375376..ce35a4e07 100644 --- a/src/admin/tainacan-admin-i18n.php +++ b/src/admin/tainacan-admin-i18n.php @@ -1,6 +1,6 @@ __( 'Repository', 'tainacan' ), 'collections' => __( 'Collections', 'tainacan' ), @@ -40,6 +40,7 @@ return apply_filters('tainacan-js-i18n', [ 'add_items_bulk' => __( 'Add items in bulk', 'tainacan' ), 'add_items_external_source' => __( 'Add items from an external source', 'tainacan' ), 'new_mapped_item' => __( 'New mapped collection', 'tainacan' ), + 'new_blank_collection' => __( 'New Blank Collection', 'tainacan' ), // Wordpress Status 'publish' => __( 'Publish', 'tainacan' ), From 2c681f02ee87c3f659f71613e982aa0f3c067e71 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Thu, 24 May 2018 11:51:58 -0300 Subject: [PATCH 014/202] add dropdown menu with route to create mapped colletions --- src/admin/pages/lists/collections-page.vue | 39 +++++++++++++++++----- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/admin/pages/lists/collections-page.vue b/src/admin/pages/lists/collections-page.vue index 0970b1253..fbdee3745 100644 --- a/src/admin/pages/lists/collections-page.vue +++ b/src/admin/pages/lists/collections-page.vue @@ -1,5 +1,6 @@ diff --git a/src/admin/pages/lists/items-page.vue b/src/admin/pages/lists/items-page.vue index 07bde8c91..9c40cf2c3 100644 --- a/src/admin/pages/lists/items-page.vue +++ b/src/admin/pages/lists/items-page.vue @@ -241,8 +241,8 @@
- - + @@ -332,7 +332,7 @@ import ItemsList from '../../components/lists/items-list.vue'; import FiltersItemsList from '../../components/search/filters-items-list.vue'; import Pagination from '../../components/search/pagination.vue' - import AdvancedSearch from '../../components/advanced-search/advanced-search.vue'; + // import AdvancedSearch from '../../components/advanced-search/advanced-search.vue'; import { mapActions, mapGetters } from 'vuex'; export default { @@ -396,7 +396,7 @@ ItemsList, FiltersItemsList, Pagination, - AdvancedSearch, + // AdvancedSearch, }, watch: { tableFields() { From 65f13161101dcca931a4df3117147ccc0accee73 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:05:22 -0300 Subject: [PATCH 111/202] Update .travis.yml --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7128ce953..c26a803e4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,11 +33,12 @@ before_install: - mysql -e 'CREATE DATABASE IF NOT EXISTS test;' install: - echo -e "Install" -- mkdir /tmp/wordpress +- mkdir /tmp/wordpress-tests-lib - mv ./tests/bootstrap-config-sample.php ./tests/bootstrap-config.php +- cat ./tests/bootstrap-config.php #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php - sudo ./tests/bin/install-wp-tests.sh test root root /tmp/wordpress localhost latest true -- ls /tmp/wordpress +- ls /tmp/wordpress/wor #- service mysql restart script: phpunit #--version #after_success: From 31f6a267f8ea3e374cd3e622e42c7cf9accc65b1 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:08:05 -0300 Subject: [PATCH 112/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c26a803e4..b27dce924 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ install: - cat ./tests/bootstrap-config.php #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php - sudo ./tests/bin/install-wp-tests.sh test root root /tmp/wordpress localhost latest true -- ls /tmp/wordpress/wor +- ls /tmp/wordpress/wordpress-tests-lib #- service mysql restart script: phpunit #--version #after_success: From fee9db084cdca69eb5b0cdf272112a11f844b2bb Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:08:29 -0300 Subject: [PATCH 113/202] Update bootstrap-config-sample.php --- tests/bootstrap-config-sample.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap-config-sample.php b/tests/bootstrap-config-sample.php index 6517be2a0..408a11228 100644 --- a/tests/bootstrap-config-sample.php +++ b/tests/bootstrap-config-sample.php @@ -1,7 +1,7 @@ '/tmp/wordpress/wodpress-tests-lib', + 'tests_dir' => '/tmp/wordpress/wordpress-tests-lib', ]; From aa0f4741acd9683bcf2bad34c717336f94155d6e Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:17:16 -0300 Subject: [PATCH 114/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b27dce924..2572db4dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ install: - cat ./tests/bootstrap-config.php #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php - sudo ./tests/bin/install-wp-tests.sh test root root /tmp/wordpress localhost latest true -- ls /tmp/wordpress/wordpress-tests-lib +- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart script: phpunit #--version #after_success: From a5de06234ea53c52cc223a9e90a7d34aaf442f96 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:22:47 -0300 Subject: [PATCH 115/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2572db4dd..e0c43bde8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ before_install: # -in deploy_rsa.enc -out deploy_rsa -d #Instalando Mysql - sudo apt-get install sshpass -- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('root') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;" +- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('root') where User='root'; update user set plugin='mysql_native_password'; GRANT ALL PRIVILEGES ON * . * TO 'root'@'localhost'; FLUSH PRIVILEGES;" #- sudo mysql_upgrade - sudo service mysql restart - mysql -e 'CREATE DATABASE IF NOT EXISTS test;' From c91ed24dd8b8d0414c602283a687fc1bf03e5a39 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:28:34 -0300 Subject: [PATCH 116/202] Update .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e0c43bde8..acc95c869 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,8 @@ before_install: # -in deploy_rsa.enc -out deploy_rsa -d #Instalando Mysql - sudo apt-get install sshpass -- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('root') where User='root'; update user set plugin='mysql_native_password'; GRANT ALL PRIVILEGES ON * . * TO 'root'@'localhost'; FLUSH PRIVILEGES;" +- mysql -u travis +#- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('root') where User='root'; update user set plugin='mysql_native_password'; GRANT ALL PRIVILEGES ON * . * TO 'root'@'localhost'; FLUSH PRIVILEGES;" #- sudo mysql_upgrade - sudo service mysql restart - mysql -e 'CREATE DATABASE IF NOT EXISTS test;' From ef56e0523c2c938c1e7c2a6b5c5282a703eeb251 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:31:59 -0300 Subject: [PATCH 117/202] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index acc95c869..1443a5c80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,8 +27,8 @@ before_install: # -in deploy_rsa.enc -out deploy_rsa -d #Instalando Mysql - sudo apt-get install sshpass -- mysql -u travis -#- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('root') where User='root'; update user set plugin='mysql_native_password'; GRANT ALL PRIVILEGES ON * . * TO 'root'@'localhost'; FLUSH PRIVILEGES;" +#- mysql -u travis +- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('travis') where User='travis'; update user set plugin='mysql_native_password'; FLUSH PRIVILEGES;" #- sudo mysql_upgrade - sudo service mysql restart - mysql -e 'CREATE DATABASE IF NOT EXISTS test;' @@ -38,7 +38,7 @@ install: - mv ./tests/bootstrap-config-sample.php ./tests/bootstrap-config.php - cat ./tests/bootstrap-config.php #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php -- sudo ./tests/bin/install-wp-tests.sh test root root /tmp/wordpress localhost latest true +- sudo ./tests/bin/install-wp-tests.sh test travis travis /tmp/wordpress localhost latest true - cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart script: phpunit #--version From ed2f5cb021dc49088e0ddad758c3ba191131b6f5 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:34:10 -0300 Subject: [PATCH 118/202] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1443a5c80..5809456e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ before_install: #Instalando Mysql - sudo apt-get install sshpass #- mysql -u travis -- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('travis') where User='travis'; update user set plugin='mysql_native_password'; FLUSH PRIVILEGES;" +#- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('travis') where User='travis'; update user set plugin='mysql_native_password'; FLUSH PRIVILEGES;" #- sudo mysql_upgrade - sudo service mysql restart - mysql -e 'CREATE DATABASE IF NOT EXISTS test;' @@ -38,7 +38,7 @@ install: - mv ./tests/bootstrap-config-sample.php ./tests/bootstrap-config.php - cat ./tests/bootstrap-config.php #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php -- sudo ./tests/bin/install-wp-tests.sh test travis travis /tmp/wordpress localhost latest true +- sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true - cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart script: phpunit #--version From f79d753588d759d230007783a97dca6894538892 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:41:26 -0300 Subject: [PATCH 119/202] Update .travis.yml --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5809456e1..0c720505c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,10 +36,11 @@ install: - echo -e "Install" - mkdir /tmp/wordpress-tests-lib - mv ./tests/bootstrap-config-sample.php ./tests/bootstrap-config.php -- cat ./tests/bootstrap-config.php +#- cat ./tests/bootstrap-config.php #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php - sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true -- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php +- composer install +#- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart script: phpunit #--version #after_success: From 82aac06165db8e5dc2c34bc01d073eecdc96333d Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:49:52 -0300 Subject: [PATCH 120/202] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0c720505c..188bf1a80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,15 +34,15 @@ before_install: - mysql -e 'CREATE DATABASE IF NOT EXISTS test;' install: - echo -e "Install" -- mkdir /tmp/wordpress-tests-lib -- mv ./tests/bootstrap-config-sample.php ./tests/bootstrap-config.php +#- sudo mkdir /tmp/wordpress-tests-lib +- sudo mv ./tests/bootstrap-config-sample.php ./tests/bootstrap-config.php #- cat ./tests/bootstrap-config.php #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php - sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true - composer install #- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart -script: phpunit #--version +script: sudo phpunit #--version #after_success: #- openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv # -in deploy_rsa.enc -out /tmp/deploy_rsa -d From 3c3f53972e802e19b54492389b119f66f5696b78 Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 4 Jun 2018 15:52:42 -0300 Subject: [PATCH 121/202] add dependencies capabilities for cases like when we edit items need to use the crop image feature so we need upload_files capability --- src/classes/class-tainacan-capabilities.php | 58 +++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/classes/class-tainacan-capabilities.php b/src/classes/class-tainacan-capabilities.php index 8a50d247c..7fe656ca2 100644 --- a/src/classes/class-tainacan-capabilities.php +++ b/src/classes/class-tainacan-capabilities.php @@ -268,6 +268,16 @@ class Capabilities { ] ], ]; + + public static $dependencies = [ + "tainacan-items" => [ + 'edit_posts' => 'upload_files', + "edit_private_posts" => 'upload_files', + "edit_published_posts" => 'upload_files', + "edit_others_posts" => 'upload_files' + ] + ]; + private static $instance = null; public static function get_instance() @@ -349,6 +359,39 @@ class Capabilities { return $translations; } + protected function check_dependencies($role, $post_type, $cap, $add = true) { + if( + array_key_exists($post_type, self::$dependencies) && + array_key_exists($cap, self::$dependencies[$post_type]) + ) { + $added = false; + if(! $role->has_cap(self::$dependencies[$post_type][$cap]) && $add) { + $role->add_cap(self::$dependencies[$post_type][$cap]); + $added = true; + } + if($role instanceof \WP_User && $add) { //moderator + $append_caps = get_user_meta($role->ID, '.tainacan-dependecies-caps', true); + if(! is_array($append_caps)) $append_caps = []; + if( + (! array_key_exists(self::$dependencies[$post_type][$cap], $append_caps) && $added ) || // we never added and need to add + ( $append_caps[self::$dependencies[$post_type][$cap]] === false && $added ) // we added but before is not need to add + ) { + $append_caps[self::$dependencies[$post_type][$cap]] = 0; + } + else { // we to not added this cap + $append_caps[self::$dependencies[$post_type][$cap]] = false; + } + if($append_caps[self::$dependencies[$post_type][$cap]] !== false) { + $append_caps[self::$dependencies[$post_type][$cap]]++; // add 1 to each collection he is a moderator + update_user_meta($role->ID, '.tainacan-dependecies-caps', $append_caps); + } + } + return self::$dependencies[$post_type][$cap]; + } + return false; + } + + /** * Update post_type caps using WordPress basic roles and register tainacan roles */ @@ -368,6 +411,7 @@ class Capabilities { foreach ($caps as $cap) { $role->add_cap($entity_cap->$cap); + $this->check_dependencies($role, $post_type, $cap); } $tainacan_roles = $this->get_tainacan_roles(); @@ -384,6 +428,7 @@ class Capabilities { foreach ($caps as $cap) { $tainacan_role->add_cap($entity_cap->$cap); + $this->check_dependencies($tainacan_role, $post_type, $cap); } } @@ -414,6 +459,7 @@ class Capabilities { foreach ($caps as $cap) { $role->add_cap($collection_items_caps->$cap); + $this->check_dependencies($role, 'tainacan-items', $cap); } } @@ -464,6 +510,17 @@ class Capabilities { $caps = $defaults_caps['tainacan-items']['editor']; foreach ($caps as $cap) { $user->remove_cap($collection_items_caps->$cap); + $dep_cap = $this->check_dependencies($user, 'tainacan-items', $cap, false); + if($dep_cap !== false) { + $appended_caps = get_user_meta($user->ID, '.tainacan-dependecies-caps', true); + if(array_key_exists($dep_cap, $appended_caps) && $appended_caps[$dep_cap] !== false && $appended_caps[$dep_cap] > 0) { + $appended_caps[$dep_cap]--; + update_user_meta($user->ID, '.tainacan-dependecies-caps', $appended_caps); + if($appended_caps == 0) { // they are not a moderator of a collection, remove cap at all + $user->remove_cap($cap); + } + } + } } } } @@ -487,6 +544,7 @@ class Capabilities { $caps = $defaults_caps['tainacan-items']['editor']; foreach ($caps as $cap) { $user->add_cap($collection_items_caps->$cap); + $this->check_dependencies($user, 'tainacan-items', $cap); } } } From c3fed59437fdbdc560e6f1bcfd45c65760296b4c Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:52:44 -0300 Subject: [PATCH 122/202] Update .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 188bf1a80..c7e2ed933 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,9 +40,10 @@ install: #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php - sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true - composer install +- ls /tmp/wordpress/wordpress-tests-lib/wp-content #- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart -script: sudo phpunit #--version +script: phpunit #--version #after_success: #- openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv # -in deploy_rsa.enc -out /tmp/deploy_rsa -d From 59abfc6fb3a9cd5ef355a88cf65a1cadb09eb47c Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 4 Jun 2018 15:53:03 -0300 Subject: [PATCH 123/202] simple dependencies capabilities test --- tests/test-default-capabilities.php | 76 +++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 3 deletions(-) diff --git a/tests/test-default-capabilities.php b/tests/test-default-capabilities.php index cb7ad4ec5..be644eed6 100644 --- a/tests/test-default-capabilities.php +++ b/tests/test-default-capabilities.php @@ -49,10 +49,80 @@ class DefaultCapabilities extends TAINACAN_UnitTestCase { $this->assertTrue(current_user_can($entity_cap->$cap), "tainacan-$role_name does not have capability {$entity_cap->$cap}"); } } - - } } - + } + + /** + * @group capabilities_denpendecies + */ + function test_capabilities_denpendecies() { + + $collection = $this->tainacan_entity_factory->create_entity( + 'collection', + array( + 'name' => 'test capabilities denpendecies', + ), + true + ); + $item = $this->tainacan_entity_factory->create_entity( + 'item', + array( + 'title' => 'test capabilities denpendecies Item', + 'collection' => $collection, + ), + true + ); + + $Tainacan_Capabilities = \Tainacan\Capabilities::get_instance(); + $deps = $Tainacan_Capabilities::$dependencies; + $defaults_caps = $Tainacan_Capabilities->defaults; + $tainacan_roles = $Tainacan_Capabilities->get_tainacan_roles(); + + foreach ($defaults_caps as $post_type => $wp_append_roles) { + if(array_key_exists($post_type, $deps)) { + $entity = false; + $entity_cap = false; + + if($post_type != 'tainacan-items') { + $entity = Repository::get_entity_by_post_type($post_type); + $entity_cap = $entity->get_capabilities(); + } + + foreach ($wp_append_roles as $role_name => $caps) { + $role = get_role($role_name); + + $new_user = $this->factory()->user->create(array( 'role' => $role_name )); + wp_set_current_user($new_user); + + foreach ($caps as $cap) { + if(array_key_exists($cap, $deps[$post_type])) { + $dep_cap = $deps[$post_type][$cap]; + if($post_type == 'tainacan-items') { + $this->assertTrue(current_user_can($dep_cap), "$role_name does not have a dependency capability {$dep_cap} for tainacan-items" ); + } else { + $this->assertTrue(current_user_can($dep_cap), "$role_name does not have a dependency capability {$dep_cap} for {$entity_cap->$cap}" ); + } + } + } + + $new_user = $this->factory()->user->create(array( 'role' => 'tainacan-' . $role_name )); + wp_set_current_user($new_user); + + if(in_array($role_name, $tainacan_roles) ) { + foreach ($caps as $cap) { + if(array_key_exists($cap, $deps[$post_type])) { + $dep_cap = $deps[$post_type][$cap]; + if($post_type == 'tainacan-items') { + $this->assertTrue(current_user_can($dep_cap), "tainaca-$role_name does not have a dependency capability {$dep_cap} for tainacan-items" ); + } else { + $this->assertTrue(current_user_can($dep_cap), "tainaca-$role_name does not have a dependency capability {$dep_cap} for {$entity_cap->$cap}" ); + } + } + } + } + } + } + } } } \ No newline at end of file From 2ce49ce45c7ef022d63f3fb13a3ad2fd7838648e Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:55:33 -0300 Subject: [PATCH 124/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c7e2ed933..9f556cf9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ install: - sudo mv ./tests/bootstrap-config-sample.php ./tests/bootstrap-config.php #- cat ./tests/bootstrap-config.php #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php -- sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true +- ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true - composer install - ls /tmp/wordpress/wordpress-tests-lib/wp-content #- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php From 3581874b7e6e8f1e016f411e4dfc0fac96e8a408 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 15:57:40 -0300 Subject: [PATCH 125/202] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9f556cf9b..3ea83d0f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,9 +38,9 @@ install: - sudo mv ./tests/bootstrap-config-sample.php ./tests/bootstrap-config.php #- cat ./tests/bootstrap-config.php #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php -- ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true +- sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true - composer install -- ls /tmp/wordpress/wordpress-tests-lib/wp-content +- sudo ls /tmp/wordpress/wordpress-tests-lib/wp-content #- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart script: phpunit #--version From 6444dba487841ebf3a0be3bc52340434b3046e76 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 16:06:14 -0300 Subject: [PATCH 126/202] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3ea83d0f0..2ad60ffb5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,10 +40,10 @@ install: #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php - sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true - composer install -- sudo ls /tmp/wordpress/wordpress-tests-lib/wp-content +- sudo mkdir /tmp/wordpress/wordpress-tests/wp-content/uploads #- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart -script: phpunit #--version +script: phpunit #--version #after_success: #- openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv # -in deploy_rsa.enc -out /tmp/deploy_rsa -d From 618c3580ad9b04fc5f8743a2e95fde96296382c9 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Mon, 4 Jun 2018 16:06:45 -0300 Subject: [PATCH 127/202] Adds most of new Modals styling from Design team changes. --- .../edition/category-edition-form.vue | 17 +++--- .../edition/collection-edition-form.vue | 2 + .../components/edition/item-edition-form.vue | 17 +++--- .../components/lists/categories-list.vue | 12 +++- .../components/lists/collections-list.vue | 12 +++- src/admin/components/lists/fields-list.vue | 19 +++--- src/admin/components/lists/filters-list.vue | 19 +++--- src/admin/components/lists/items-list.vue | 12 +++- src/admin/components/lists/terms-list.vue | 15 +++-- src/admin/scss/_modals.scss | 60 ++++++++++++++++++- src/admin/scss/_variables.scss | 1 + src/admin/tainacan-admin-i18n.php | 2 + 12 files changed, 143 insertions(+), 45 deletions(-) diff --git a/src/admin/components/edition/category-edition-form.vue b/src/admin/components/edition/category-edition-form.vue index 0c50a64da..e5f973225 100644 --- a/src/admin/components/edition/category-edition-form.vue +++ b/src/admin/components/edition/category-edition-form.vue @@ -195,14 +195,17 @@ if (formNotSaved) { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.$i18n.get('info_warning_category_not_saved'), - onConfirm: () => { - next(); - }, - cancelText: this.$i18n.get('cancel'), - confirmText: this.$i18n.get('continue'), - type: 'is-secondary' - }); + onConfirm: () => { + next(); + }, + icon: 'alert-circle', + hasIcon: true, + cancelText: this.$i18n.get('cancel'), + confirmText: this.$i18n.get('continue'), + type: 'is-success' + }); } else { next() } diff --git a/src/admin/components/edition/collection-edition-form.vue b/src/admin/components/edition/collection-edition-form.vue index 30c03068b..9bcc36dce 100644 --- a/src/admin/components/edition/collection-edition-form.vue +++ b/src/admin/components/edition/collection-edition-form.vue @@ -301,6 +301,7 @@ class="control" custom> {{ registeredViewModes[viewMode].label }} @@ -326,6 +327,7 @@ @focus="clearErrors('default_view_mode')"> diff --git a/src/admin/components/edition/item-edition-form.vue b/src/admin/components/edition/item-edition-form.vue index 921a2fe3e..aa8b805c1 100644 --- a/src/admin/components/edition/item-edition-form.vue +++ b/src/admin/components/edition/item-edition-form.vue @@ -676,14 +676,17 @@ export default { beforeRouteLeave ( to, from, next ) { if (this.item.status == 'auto-draft') { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.$i18n.get('info_warning_item_not_saved'), - onConfirm: () => { - next(); - }, - cancelText: this.$i18n.get('cancel'), - confirmText: this.$i18n.get('continue'), - type: 'is-secondary' - }); + onConfirm: () => { + next(); + }, + icon: 'alert-circle', + hasIcon: true, + cancelText: this.$i18n.get('cancel'), + confirmText: this.$i18n.get('continue'), + type: 'is-success' + }); } else { next() } diff --git a/src/admin/components/lists/categories-list.vue b/src/admin/components/lists/categories-list.vue index 60d4db813..985d10fcb 100644 --- a/src/admin/components/lists/categories-list.vue +++ b/src/admin/components/lists/categories-list.vue @@ -180,6 +180,7 @@ }, deleteOneCategory(categoryId) { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.$i18n.get('info_warning_category_delete'), onConfirm: () => { this.deleteCategory(categoryId) @@ -205,11 +206,15 @@ // queue: true // }); }); - } + }, + icon: 'alert-circle', + hasIcon: true, + type: 'is-success' }); }, deleteSelectedCategories() { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.$i18n.get('info_warning_selected_categories_delete'), onConfirm: () => { @@ -237,7 +242,10 @@ } } this.allCategoriesOnPageSelected = false; - } + }, + icon: 'alert-circle', + hasIcon: true, + type: 'is-success' }); }, goToCategoryPage(categoryId) { diff --git a/src/admin/components/lists/collections-list.vue b/src/admin/components/lists/collections-list.vue index f4630dcfb..1c70f6143 100644 --- a/src/admin/components/lists/collections-list.vue +++ b/src/admin/components/lists/collections-list.vue @@ -230,6 +230,7 @@ export default { }, deleteOneCollection(collectionId) { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.isOnTrash ? this.$i18n.get('info_warning_collection_delete') : this.$i18n.get('info_warning_collection_trash'), onConfirm: () => { this.deleteCollection({ collectionId: collectionId, isPermanently: this.isOnTrash }) @@ -254,11 +255,15 @@ export default { // queue: true // }) }); - } + }, + icon: 'alert-circle', + hasIcon: true, + type: 'is-success' }); }, deleteSelectedCollections() { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.isOnTrash ? this.$i18n.get('info_warning_selected_collections_delete') : this.$i18n.get('info_warning_selected_collections_trash'), onConfirm: () => { @@ -286,7 +291,10 @@ export default { } } this.allCollectionsOnPageSelected = false; - } + }, + icon: 'alert-circle', + hasIcon: true, + type: 'is-success' }); }, goToCollectionPage(collectionId) { diff --git a/src/admin/components/lists/fields-list.vue b/src/admin/components/lists/fields-list.vue index dfb25e567..aaed4f7e7 100644 --- a/src/admin/components/lists/fields-list.vue +++ b/src/admin/components/lists/fields-list.vue @@ -195,15 +195,18 @@ export default { } if ((this.openedFieldId != '' && this.openedFieldId != undefined) || hasUnsavedForms ) { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.$i18n.get('info_warning_fields_not_saved'), - onConfirm: () => { - this.onEditionCanceled(); - next(); - }, - cancelText: this.$i18n.get('cancel'), - confirmText: this.$i18n.get('continue'), - type: 'is-secondary' - }); + onConfirm: () => { + this.onEditionCanceled(); + next(); + }, + icon: 'alert-circle', + hasIcon: true, + cancelText: this.$i18n.get('cancel'), + confirmText: this.$i18n.get('continue'), + type: 'is-success' + }); } else { next() } diff --git a/src/admin/components/lists/filters-list.vue b/src/admin/components/lists/filters-list.vue index b2f184081..a05dc6e11 100644 --- a/src/admin/components/lists/filters-list.vue +++ b/src/admin/components/lists/filters-list.vue @@ -222,15 +222,18 @@ export default { } if ((this.openedFilterId != '' && this.openedFilterId != undefined) || hasUnsavedForms ) { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.$i18n.get('info_warning_filters_not_saved'), - onConfirm: () => { - this.onEditionCanceled(); - next(); - }, - cancelText: this.$i18n.get('cancel'), - confirmText: this.$i18n.get('continue'), - type: 'is-secondary' - }); + onConfirm: () => { + this.onEditionCanceled(); + next(); + }, + icon: 'alert-circle', + hasIcon: true, + cancelText: this.$i18n.get('cancel'), + confirmText: this.$i18n.get('continue'), + type: 'is-success' + }); } else { next() } diff --git a/src/admin/components/lists/items-list.vue b/src/admin/components/lists/items-list.vue index 35f1153cd..0d887c83a 100644 --- a/src/admin/components/lists/items-list.vue +++ b/src/admin/components/lists/items-list.vue @@ -214,6 +214,7 @@ export default { }, deleteOneItem(itemId) { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.isOnTrash ? this.$i18n.get('info_warning_item_delete') : this.$i18n.get('info_warning_item_trash'), onConfirm: () => { this.deleteItem({ itemId: itemId, isPermanently: this.isOnTrash }) @@ -239,11 +240,15 @@ export default { // queue: true // }) }); - } + }, + icon: 'alert-circle', + hasIcon: true, + type: 'is-success' }); }, deleteSelectedItems() { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.isOnTrash ? this.$i18n.get('info_warning_selected_items_delete') : this.$i18n.get('info_warning_selected_items_trash'), onConfirm: () => { @@ -275,7 +280,10 @@ export default { } } this.allItemsOnPageSelected = false; - } + }, + icon: 'alert-circle', + hasIcon: true, + type: 'is-success' }); }, goToItemPage(item) { diff --git a/src/admin/components/lists/terms-list.vue b/src/admin/components/lists/terms-list.vue index 918ff369a..9a0586306 100644 --- a/src/admin/components/lists/terms-list.vue +++ b/src/admin/components/lists/terms-list.vue @@ -213,13 +213,16 @@ export default { // Checks if user is deleting a term with unsaved info. if (term.id == 'new' || !term.saved || term.opened) { this.$dialog.confirm({ + title: this.$i18n.get('label_warning'), message: this.$i18n.get('info_warning_terms_not_saved'), - onCancel: () => { return }, - onConfirm: () => { this.removeTerm(term);}, - cancelText: this.$i18n.get('cancel'), - confirmText: this.$i18n.get('continue'), - type: 'is-secondary' - }); + onCancel: () => { return }, + onConfirm: () => { this.removeTerm(term); }, + icon: 'alert-circle', + hasIcon: true, + cancelText: this.$i18n.get('cancel'), + confirmText: this.$i18n.get('continue'), + type: 'is-success' + }); } else{ this.removeTerm(term); } diff --git a/src/admin/scss/_modals.scss b/src/admin/scss/_modals.scss index 637c2ad51..2e517cd91 100644 --- a/src/admin/scss/_modals.scss +++ b/src/admin/scss/_modals.scss @@ -1,4 +1,3 @@ - // Tainacan modals .tainacan-modal-title { h1, h2 { @@ -35,9 +34,64 @@ padding: 80px 0em 0.4em 0em !important; } } +// Bulma modals customized for Tainacan +.dialog{ + .modal-background { + background-color: rgba(0, 0, 0, 0.70); + } + .modal-card { + background-color: $modal-backgound-color; + color: $secondary; + border-radius: 10px; -.modal-background { - background-color: rgba(0, 0, 0, 0.70); + .modal-card-head, .modal-card-body, .modal-card-foot { + background-color: $modal-backgound-color; + color: $secondary; + border: none; + } + .modal-card-head { + p { color: $secondary; } + font-weight: normal; + padding: 30px 35px 0px 35px; + } + .modal-card-body { + padding: 16px 35px; + + i { + color: white !important; + &::before { + background-color: $danger; + border-radius: 55px; + display: initial; + } + } + } + .modal-card-foot { + justify-content: space-between; + padding: 0px 35px 30px 35px; + + .button { + border-radius: 6px !important; + font-weight: normal; + padding: 2px 15px !important; + margin-top: 0px !important; + margin-bottom: 0px !important; + height: inherit !important; + box-shadow: none !important; + display: inline-flex !important; + cursor: pointer; + font-size: 13px !important; + } + .button.is-success { + border: none; + } + .button:not(.is-success) { + background-color: white; + color: $tertiary; + border: 1px solid $gray-light; + } + } + } } // WordPress Media Modal customization diff --git a/src/admin/scss/_variables.scss b/src/admin/scss/_variables.scss index 1e46513db..d0848ebce 100644 --- a/src/admin/scss/_variables.scss +++ b/src/admin/scss/_variables.scss @@ -18,6 +18,7 @@ $primary-darker: darken($primary-dark, 5%); $success: #25a189; $success-invert: findColorInvert($success); +$modal-backgound-color: #bfd8dd; $separator-color: #2b98a4; $tainacan-input-color: #1d1d1d; $tainacan-input-background: #e5e5e5; diff --git a/src/admin/tainacan-admin-i18n.php b/src/admin/tainacan-admin-i18n.php index d784127ae..36f06217f 100644 --- a/src/admin/tainacan-admin-i18n.php +++ b/src/admin/tainacan-admin-i18n.php @@ -197,6 +197,8 @@ return [ 'label_default_view_mode' => __( 'Default view mode', 'tainacan' ), 'label_enabled_view_modes' => __( 'Enabled view modes', 'tainacan' ), 'label_view_modes_available' => __( 'View modes available on theme', 'tainacan' ), + 'label_warning' => __( 'Warning', 'tainacan' ), + 'label_error' => __( 'Erro', 'tainacan' ), // Instructions. More complex sentences to guide user and placeholders 'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ), From c9f76395343d3b963827b23badc362aeedd02556 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 16:08:47 -0300 Subject: [PATCH 128/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2ad60ffb5..f8c330ceb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ install: #- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php - sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true - composer install -- sudo mkdir /tmp/wordpress/wordpress-tests/wp-content/uploads +- sudo mkdir /tmp/wordpress/wordpress-test/wp-content/uploads #- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart script: phpunit #--version From da2e7a2b4d55f74701b8b24c45e1c85751d8e1bd Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 4 Jun 2018 16:15:19 -0300 Subject: [PATCH 129/202] missing array key check --- src/classes/class-tainacan-capabilities.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/classes/class-tainacan-capabilities.php b/src/classes/class-tainacan-capabilities.php index 7fe656ca2..f9ae0dcd4 100644 --- a/src/classes/class-tainacan-capabilities.php +++ b/src/classes/class-tainacan-capabilities.php @@ -374,7 +374,11 @@ class Capabilities { if(! is_array($append_caps)) $append_caps = []; if( (! array_key_exists(self::$dependencies[$post_type][$cap], $append_caps) && $added ) || // we never added and need to add - ( $append_caps[self::$dependencies[$post_type][$cap]] === false && $added ) // we added but before is not need to add + ( + array_key_exists(self::$dependencies[$post_type][$cap], $append_caps) && + $append_caps[self::$dependencies[$post_type][$cap]] === false && + $added + ) // we added but before is not need to add ) { $append_caps[self::$dependencies[$post_type][$cap]] = 0; } From a08fdf0693e1a51d428e2dd985c69dc59b2ebcad Mon Sep 17 00:00:00 2001 From: Jacson Passold Date: Mon, 4 Jun 2018 16:15:37 -0300 Subject: [PATCH 130/202] missing assert --- tests/test-api-export.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test-api-export.php b/tests/test-api-export.php index 59041e9b1..6a0168779 100644 --- a/tests/test-api-export.php +++ b/tests/test-api-export.php @@ -110,7 +110,8 @@ class TAINACAN_REST_Export_Controller extends TAINACAN_UnitApiTestCase { $response = $this->server->dispatch($request); $this->assertEquals(200, $response->get_status()); $data = $response->get_data(); - print_r($data); + + $this->assertInstanceOf('SimpleXMLElement', @simplexml_load_string($data)); } } From cae6f00a9b50b92a93c9c44edcf4d5ec8e3bfbfd Mon Sep 17 00:00:00 2001 From: walisonjose Date: Mon, 4 Jun 2018 16:22:27 -0300 Subject: [PATCH 131/202] Update .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index f8c330ceb..f10e04cca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,13 @@ sudo: false language: php php: - 7.1 +- 5.6 - hhvm - nightly matrix: allow_failures: - php: 7.1 + - php: 5.6 - php: hhvm - php: nightly fast_finish: true From 6b3e2738571b39595ccdc316c66e296c8f51d61a Mon Sep 17 00:00:00 2001 From: weryques Date: Mon, 4 Jun 2018 16:29:22 -0300 Subject: [PATCH 132/202] Fixes errors in tests and fixes has content in Custom Interval component --- .../endpoints/class-tainacan-rest-filters-controller.php | 2 +- .../filter-types/custom-interval/CustomInterval.vue | 8 ++++---- src/importer/class-tainacan-importer.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/api/endpoints/class-tainacan-rest-filters-controller.php b/src/api/endpoints/class-tainacan-rest-filters-controller.php index c1e9d168c..7a93f4c13 100644 --- a/src/api/endpoints/class-tainacan-rest-filters-controller.php +++ b/src/api/endpoints/class-tainacan-rest-filters-controller.php @@ -327,7 +327,7 @@ class REST_Filters_Controller extends REST_Controller { $item_arr['enabled'] = $item->get_enabled_for_collection(); } - $item_arr['filter_type_object'] = $item->get_filter_type_object()->_toArray(); + $item_arr['filter_type_object'] = $item->get_filter_type_object() ? $item->get_filter_type_object()->_toArray() : $item->get_filter_type_object(); return $item_arr; } diff --git a/src/classes/filter-types/custom-interval/CustomInterval.vue b/src/classes/filter-types/custom-interval/CustomInterval.vue index 4b08e2ef3..2ebbf6999 100644 --- a/src/classes/filter-types/custom-interval/CustomInterval.vue +++ b/src/classes/filter-types/custom-interval/CustomInterval.vue @@ -4,7 +4,7 @@
get_id().'.txt', 'w' ); fwrite( $file, $tmp['body'] ); fclose( $file ); From 7f56e379e587a5fcb60df64bfa217c601d36bdbd Mon Sep 17 00:00:00 2001 From: weryques Date: Mon, 4 Jun 2018 16:30:32 -0300 Subject: [PATCH 133/202] Initiaded advanced search (issue #22) --- .../advanced-search/advanced-search.vue | 123 ++++++++++++++++++ .../components/navigation/tainacan-header.vue | 13 +- src/admin/js/router.js | 2 +- src/admin/pages/lists/items-page.vue | 17 ++- 4 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 src/admin/components/advanced-search/advanced-search.vue diff --git a/src/admin/components/advanced-search/advanced-search.vue b/src/admin/components/advanced-search/advanced-search.vue new file mode 100644 index 000000000..27afacd4d --- /dev/null +++ b/src/admin/components/advanced-search/advanced-search.vue @@ -0,0 +1,123 @@ + + + + + \ No newline at end of file diff --git a/src/admin/components/navigation/tainacan-header.vue b/src/admin/components/navigation/tainacan-header.vue index 2f6b0abc1..5fa34bcb6 100644 --- a/src/admin/components/navigation/tainacan-header.vue +++ b/src/admin/components/navigation/tainacan-header.vue @@ -20,7 +20,7 @@
@@ -28,7 +28,7 @@
- {{ $i18n.get('advanced_search') }} + {{ $i18n.get('advanced_search') }}

- +
{{ $i18n.get('advanced_search') }}

{{ $i18n.get('filters') }}

- + @@ -361,6 +365,10 @@ enabledViewModes: Object // Used only on theme }, computed: { + openAdvancedSearch(){ + console.log('Called here', this.$route.meta); + return this.$route.meta.openAdvancedSearch; + }, items() { return this.getItems(); }, @@ -428,6 +436,11 @@ 'getViewMode', 'getTotalItems' ]), + openAdvancedSearchComponent(){ + console.log('Called here', this.$route.meta); + this.$set(this.$route.meta, 'openAdvancedSearch', !this.$route.meta.openAdvancedSearch); + console.log('Called here', this.$route.meta); + }, updateSearch() { this.$eventBusSearch.setSearchQuery(this.futureSearchQuery); }, From 980ffa7c6409d93b0aae7169f6675ff4c713d78e Mon Sep 17 00:00:00 2001 From: eduardohumberto Date: Mon, 4 Jun 2018 21:41:14 -0300 Subject: [PATCH 134/202] begin script file for import old tainacan --- src/importer/import.php | 90 +++++++++++++++++++++++++++++++++++++++++ tests/test-importer.php | 4 ++ 2 files changed, 94 insertions(+) create mode 100644 src/importer/import.php diff --git a/src/importer/import.php b/src/importer/import.php new file mode 100644 index 000000000..11d819694 --- /dev/null +++ b/src/importer/import.php @@ -0,0 +1,90 @@ +parse_args($argv); + $this->run(); + + } + + /** + * parse args from and set the attributs + * 1 - Old Tainacan url (required) + */ + function parse_args($argv) { + + if (!is_array($argv)) + return; + + + if (isset($argv[1])) { + + if (filter_var($argv[1], FILTER_VALIDATE_URL)) { + $this->url = $argv[1]; + } + + } + + if (isset($argv[2])) { + + if (is_numeric($argv[2])) { + $this->step = $argv[2]; + } else { + $this->run = ''; + } + + } + + } + + /** + * echo message in prompt line + */ + function log($msg) { + + echo $msg . PHP_EOL; + + } + + function run() { + + $start = $partial = microtime(true); + + // Avoid warnings + $_SERVER['SERVER_PROTOCOL'] = "HTTP/1.1"; + $_SERVER['REQUEST_METHOD'] = "GET"; + + define( 'WP_USE_THEMES', false ); + define( 'SHORTINIT', false ); + require( dirname(__FILE__) . '/../../../../wp-blog-header.php' ); + + $old_tainacan = new \Tainacan\Importer\Old_Tainacan(); + $id = $old_tainacan->get_id(); + + $_SESSION['tainacan_importer'][$id]->set_url($url); + $_SESSION['tainacan_importer'][$id]->set_repository(); + + while (!$_SESSION['tainacan_importer'][$id]->is_finished()){ + $_SESSION['tainacan_importer'][$id]->run(); + } + + $scripttime = microtime(true) - $start; + + $this->log("=========================================================="); + $this->log("=========================================================="); + $this->log("=== Fim do script. Tempo de execução {$scripttime}s"); + $this->log("=========================================================="); + $this->log("=========================================================="); + + } +} + +$x = new ScriptTainacanOld($argv); \ No newline at end of file diff --git a/tests/test-importer.php b/tests/test-importer.php index 908d074c1..064c5e66f 100644 --- a/tests/test-importer.php +++ b/tests/test-importer.php @@ -55,6 +55,10 @@ class ImporterTests extends TAINACAN_UnitTestCase { $_SESSION['tainacan_importer'][$id]->run(); } + $Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance(); + $collections = $Tainacan_Collections->fetch([], 'OBJECT'); + $this->assertEquals(3, $collections, 'total collection in this url does not match'); + $this->assertTrue(true); }*/ From 0b0cdf0a4554313274ecc262fe06c89ac9277726 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Tue, 5 Jun 2018 09:27:26 -0300 Subject: [PATCH 135/202] Removes console log from header and subheader. Adds empty fecthonlt and fetchonly meta verifiction before loading items to ensure an empty array is passed. --- .../components/navigation/tainacan-header.vue | 2 - src/admin/pages/lists/items-page.vue | 3 -- src/js/store/modules/collection/actions.js | 44 ++++++++++--------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/admin/components/navigation/tainacan-header.vue b/src/admin/components/navigation/tainacan-header.vue index 5fa34bcb6..cb15d6d0e 100644 --- a/src/admin/components/navigation/tainacan-header.vue +++ b/src/admin/components/navigation/tainacan-header.vue @@ -52,9 +52,7 @@ export default { }, methods: { openAdvancedSearchComponent(){ - console.log('Called here', this.$route.meta); this.$set(this.$route.meta, 'openAdvancedSearch', !this.$route.meta.openAdvancedSearch); - console.log('Called here', this.$route.meta); } }, props: { diff --git a/src/admin/pages/lists/items-page.vue b/src/admin/pages/lists/items-page.vue index 3d2e53997..fba000fa3 100644 --- a/src/admin/pages/lists/items-page.vue +++ b/src/admin/pages/lists/items-page.vue @@ -366,7 +366,6 @@ }, computed: { openAdvancedSearch(){ - console.log('Called here', this.$route.meta); return this.$route.meta.openAdvancedSearch; }, items() { @@ -437,9 +436,7 @@ 'getTotalItems' ]), openAdvancedSearchComponent(){ - console.log('Called here', this.$route.meta); this.$set(this.$route.meta, 'openAdvancedSearch', !this.$route.meta.openAdvancedSearch); - console.log('Called here', this.$route.meta); }, updateSearch() { this.$eventBusSearch.setSearchQuery(this.futureSearchQuery); diff --git a/src/js/store/modules/collection/actions.js b/src/js/store/modules/collection/actions.js index 9d3561511..b92067ce0 100644 --- a/src/js/store/modules/collection/actions.js +++ b/src/js/store/modules/collection/actions.js @@ -13,6 +13,13 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is if (postQueries.metaquery != undefined && postQueries.metaquery.length > 0) hasFiltered = true; + // Garanttees at least empty fetch_only are passed in case none is found + if (qs.stringify(postQueries.fetch_only) == '') + postQueries.fetch_only = {}; + + if (qs.stringify(postQueries.fetch_only['meta']) == '') + postQueries.fetch_only['meta'] = [0]; + // Differentiates between repository level and collection level queries let endpoint = '/collection/'+collectionId+'/items?' @@ -22,26 +29,23 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is if (!isOnTheme) endpoint = endpoint + 'context=edit&' - if (qs.stringify(postQueries.fetch_only['meta']) != '') { - axios.tainacan.get(endpoint + qs.stringify(postQueries)) - .then(res => { - - let items = res.data; - let viewModeObject = tainacan_plugin.registered_view_modes[postQueries.view_mode]; - - if (isOnTheme && viewModeObject != undefined && viewModeObject.type == 'template') { - commit('setItemsListTemplate', items ); - resolve({'itemsListTemplate': items, 'total': res.headers['x-wp-total'], hasFiltered: hasFiltered}); - } else { - commit('setItems', items ); - resolve({'items': items, 'total': res.headers['x-wp-total'], hasFiltered: hasFiltered}); - } - dispatch('search/setTotalItems', res.headers['x-wp-total'], { root: true } ); - }) - .catch(error => reject(error)); - } else { - reject("No fecth_only meta was found."); - } + axios.tainacan.get(endpoint + qs.stringify(postQueries)) + .then(res => { + + let items = res.data; + let viewModeObject = tainacan_plugin.registered_view_modes[postQueries.view_mode]; + + if (isOnTheme && viewModeObject != undefined && viewModeObject.type == 'template') { + commit('setItemsListTemplate', items ); + resolve({'itemsListTemplate': items, 'total': res.headers['x-wp-total'], hasFiltered: hasFiltered}); + } else { + commit('setItems', items ); + resolve({'items': items, 'total': res.headers['x-wp-total'], hasFiltered: hasFiltered}); + } + dispatch('search/setTotalItems', res.headers['x-wp-total'], { root: true } ); + }) + .catch(error => reject(error)); + }); } From eb78a8f3b9a84e98331fa62ef3c32165c9c517c1 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Tue, 5 Jun 2018 09:57:08 -0300 Subject: [PATCH 136/202] Solves vuex mutation warning after previous commit. --- src/js/store/modules/collection/actions.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/js/store/modules/collection/actions.js b/src/js/store/modules/collection/actions.js index b92067ce0..0a0f6497e 100644 --- a/src/js/store/modules/collection/actions.js +++ b/src/js/store/modules/collection/actions.js @@ -14,11 +14,11 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is hasFiltered = true; // Garanttees at least empty fetch_only are passed in case none is found - if (qs.stringify(postQueries.fetch_only) == '') - postQueries.fetch_only = {}; - - if (qs.stringify(postQueries.fetch_only['meta']) == '') - postQueries.fetch_only['meta'] = [0]; + if (qs.stringify(postQueries.fetch_only) == '') + dispatch('search/add_fetchonly', {} , { root: true }); + + if (qs.stringify(postQueries.fetch_only['meta']) == '') + dispatch('search/add_fetchonly_meta', 0 , { root: true }); // Differentiates between repository level and collection level queries let endpoint = '/collection/'+collectionId+'/items?' From 0c794846ffaa7a2e15ad0ed4fdb95d78e0c9ed7e Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 10:24:19 -0300 Subject: [PATCH 137/202] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f10e04cca..eba1478f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -79,6 +79,7 @@ cache: - vendor - composer notifications: + slack: l3pol:wG8WvtgdhXIR6sN4NfSNoela email: on_success: never on_failure: always From 8426e0a1da1b7a24e94bb77e138214408373c1f0 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 10:30:09 -0300 Subject: [PATCH 138/202] Update .travis.yml --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index eba1478f4..a5d1dc2b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,14 +3,14 @@ language: php php: - 7.1 - 5.6 -- hhvm -- nightly +#- hhvm +#- nightly matrix: allow_failures: - php: 7.1 - php: 5.6 - - php: hhvm - - php: nightly + # - php: hhvm + #- php: nightly fast_finish: true addons: - ssh_know_hosts: @@ -80,6 +80,7 @@ cache: - composer notifications: slack: l3pol:wG8WvtgdhXIR6sN4NfSNoela + on_sucess: always email: on_success: never on_failure: always From 1167c216ff2c0000ff791550688e83b987811b17 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 10:34:51 -0300 Subject: [PATCH 139/202] =?UTF-8?q?Notifica=C3=A7=C3=B5es=20=20Slack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a5d1dc2b0..ad57fc6c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -81,6 +81,7 @@ cache: notifications: slack: l3pol:wG8WvtgdhXIR6sN4NfSNoela on_sucess: always + on_failure: always email: on_success: never on_failure: always From c44e4af950e80c2f7ff26b82c5c1b940b495a021 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 10:39:31 -0300 Subject: [PATCH 140/202] Update .travis.yml --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ad57fc6c6..adc305453 100644 --- a/.travis.yml +++ b/.travis.yml @@ -79,7 +79,9 @@ cache: - vendor - composer notifications: - slack: l3pol:wG8WvtgdhXIR6sN4NfSNoela + slack: + l3pol:wG8WvtgdhXIR6sN4NfSNoela + enabled: true on_sucess: always on_failure: always email: From 03314a70b07ad972089a11e6c401d010a0383ecd Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 10:41:41 -0300 Subject: [PATCH 141/202] Update .travis.yml --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index adc305453..52e196e64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -79,8 +79,7 @@ cache: - vendor - composer notifications: - slack: - l3pol:wG8WvtgdhXIR6sN4NfSNoela + slack: l3pol:wG8WvtgdhXIR6sN4NfSNoela enabled: true on_sucess: always on_failure: always From e36bf6be404cf0603f98b4afe9e8500abcf3e3e1 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 10:43:02 -0300 Subject: [PATCH 142/202] Update .travis.yml --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 52e196e64..a0946d84f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -79,7 +79,9 @@ cache: - vendor - composer notifications: - slack: l3pol:wG8WvtgdhXIR6sN4NfSNoela + slack: + l3pol: + secure: wG8WvtgdhXIR6sN4NfSNoela enabled: true on_sucess: always on_failure: always From b890afa01baefaa899d9181cdc5095054fd493f5 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 10:50:39 -0300 Subject: [PATCH 143/202] Update .travis.yml --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a0946d84f..9d613c066 100644 --- a/.travis.yml +++ b/.travis.yml @@ -80,9 +80,8 @@ cache: - composer notifications: slack: - l3pol: - secure: wG8WvtgdhXIR6sN4NfSNoela - enabled: true + rooms: + - l3pol:wG8WvtgdhXIR6sN4NfSNoela on_sucess: always on_failure: always email: From 8d7109d4aecfc686b35e8e4359dcfa9402b12264 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 11:01:05 -0300 Subject: [PATCH 144/202] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9d613c066..a75423fe0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -82,8 +82,8 @@ notifications: slack: rooms: - l3pol:wG8WvtgdhXIR6sN4NfSNoela - on_sucess: always - on_failure: always + on_sucess: change + on_failure: change email: on_success: never on_failure: always From 279a4a0f0532d50a4763513e66f9f69cfd18e901 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 11:17:08 -0300 Subject: [PATCH 145/202] Update .travis.yml --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a75423fe0..0b50127c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -82,8 +82,9 @@ notifications: slack: rooms: - l3pol:wG8WvtgdhXIR6sN4NfSNoela - on_sucess: change - on_failure: change + on_sucess: always + on_failure: always + on_start: never email: on_success: never on_failure: always From 95969866c092f301606d16ad119e2d5100cb1426 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 11:20:45 -0300 Subject: [PATCH 146/202] Update .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0b50127c3..3eb5769cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,9 +43,10 @@ install: - sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true - composer install - sudo mkdir /tmp/wordpress/wordpress-test/wp-content/uploads +- phpunit #- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart -script: phpunit #--version +#script: phpunit #--version #after_success: #- openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv # -in deploy_rsa.enc -out /tmp/deploy_rsa -d From 6759350260b79e074172c634806cb224d1e6a1a5 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 11:30:57 -0300 Subject: [PATCH 147/202] Update .travis.yml --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3eb5769cd..7a8359df0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,9 @@ php: #- hhvm #- nightly matrix: - allow_failures: - - php: 7.1 - - php: 5.6 + #allow_failures: + #- php: 7.1 + #- php: 5.6 # - php: hhvm #- php: nightly fast_finish: true From 64ba7307cf3b01b4dc8e2f137de81680266087b7 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 11:35:19 -0300 Subject: [PATCH 148/202] Update .travis.yml --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7a8359df0..fed8c73e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,10 +43,9 @@ install: - sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true - composer install - sudo mkdir /tmp/wordpress/wordpress-test/wp-content/uploads -- phpunit #- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php #- service mysql restart -#script: phpunit #--version +script: phpunit #--version #after_success: #- openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv # -in deploy_rsa.enc -out /tmp/deploy_rsa -d From d131a342602310f0c937cc14d0d269da9a78b23f Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 11:38:28 -0300 Subject: [PATCH 149/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fed8c73e7..950749b49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ php: #- nightly matrix: #allow_failures: - #- php: 7.1 + - php: 7.1 #- php: 5.6 # - php: hhvm #- php: nightly From 1830bc2694a3de16f3f8ad1c447cf9d4869ed73b Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 11:39:28 -0300 Subject: [PATCH 150/202] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 950749b49..6ea45748f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ php: #- hhvm #- nightly matrix: - #allow_failures: - - php: 7.1 + allow_failures: + - php: 7.1 #- php: 5.6 # - php: hhvm #- php: nightly From 2bde4a7a5d215411c102dda90c5cc8b7aeddf0e0 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 11:42:20 -0300 Subject: [PATCH 151/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6ea45748f..5513536e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ php: #- nightly matrix: allow_failures: - - php: 7.1 + # - php: 7.1 #- php: 5.6 # - php: hhvm #- php: nightly From efa2353570ef763737de3803336f8ed6cd47662d Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 13:29:25 -0300 Subject: [PATCH 152/202] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20token=20Slack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 63 +++++++++++++++-------------------------------------- 1 file changed, 17 insertions(+), 46 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5513536e6..291161d82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,61 +3,33 @@ language: php php: - 7.1 - 5.6 -#- hhvm -#- nightly -matrix: - allow_failures: - # - php: 7.1 - #- php: 5.6 - # - php: hhvm - #- php: nightly +matrix: + allow_failures: fast_finish: true addons: - ssh_know_hosts: - - "$ssh_host" + - "$ssh_host" apt: sources: - - mysql-5.7-trusty - packages: - - sshpass - - mysql-server - - mysql-client + - mysql-5.7-trusty + packages: + - sshpass + - mysql-server + - mysql-client services: - - mysql +- mysql before_install: -#- openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv -# -in deploy_rsa.enc -out deploy_rsa -d -#Instalando Mysql - sudo apt-get install sshpass -#- mysql -u travis -#- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('travis') where User='travis'; update user set plugin='mysql_native_password'; FLUSH PRIVILEGES;" -#- sudo mysql_upgrade - sudo service mysql restart - mysql -e 'CREATE DATABASE IF NOT EXISTS test;' install: - echo -e "Install" -#- sudo mkdir /tmp/wordpress-tests-lib - sudo mv ./tests/bootstrap-config-sample.php ./tests/bootstrap-config.php -#- cat ./tests/bootstrap-config.php -#- sed 's/~//home/travis/build/wordpress/g' ./tests/bootstrap-config.php -- sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest true +- sudo ./tests/bin/install-wp-tests.sh test travis "" /tmp/wordpress localhost latest + true - composer install - sudo mkdir /tmp/wordpress/wordpress-test/wp-content/uploads -#- cat /tmp/wordpress/wordpress-tests-lib/wp-tests-config.php -#- service mysql restart -script: phpunit #--version -#after_success: -#- openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv - # -in deploy_rsa.enc -out /tmp/deploy_rsa -d -#- openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv -# -in deploy_rsa.enc -out deploy_rsa -d -#- echo -e "After success!" -#- eval "$(ssh-agent -s)" -#- chmod 600 /tmp/deploy_rsa -#- ssh-add /tmp/deploy_rsa -#- echo -e "Host $ssh_host\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config -#- ssh-add -l -#- ssh $ssh_user@$ssh_host "sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" +script: phpunit before_deploy: - echo "Seção executada antes do deploy!" - openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv @@ -67,21 +39,20 @@ before_deploy: - ssh-add /tmp/deploy_rsa - echo -e "Host $ssh_host\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config - ssh-add -l -#- ssh $ssh_user@$ssh_host "sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" deploy: - provider: script - script: echo "Faz Deploy!"#ssh $ssh_user@$ssh_host "sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" + script: echo "Faz Deploy!"#ssh $ssh_user@$ssh_host "sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" skip_cleanup: true - on: - branch: continuousintegration + on: + branch: continuousintegration cache: directories: - vendor - composer notifications: - slack: + slack: rooms: - - l3pol:wG8WvtgdhXIR6sN4NfSNoela + secure: WjgA4OIad0/Ai+x1TUd7KShXpaJco9E/MfI6DWJFnBUF5JLKOxymTGbR82wspmnEwzXGWn++co1wNJh20pWobaIToL/2OpBd7xo5MHglNobH4cidmSIDPOQM8ItqBneRjayhXtfShRqQDNCk1D3d5KDUacXXeCX+GLdRuwdc/YuG7Zh3y1KrF6l10cwD/5JOJECwwMbqeLOezvzGi8ITL6pqnEEeNTb0Zr+K2Ru91RBOars4TLK3f5CmX4XxA4oQSMsrHKzTO2OZLua5CRwcBwKmtSqr0Z/W+RrXu2TLxvHYJ39t9uwssI3HmGoB/uNcahBTcE0Vk/phi3nfFO8KUGNqp3xLgUsF/xlb+WiIip2xOf9jq+XNGWwIVB2vWqiQppm58h57LgDNTF21XJOtfVPEyf9Em+VSfNgACq47u4kktgqgZ47xNEBZuv1s3as8BcgdQH78hF+qguhhHJH6RgyHt+GYAq2uRLF8z3IM8hfKpb5mA9jD3UfW3pXEtKF9K+XqtNycX8KxJ2ldEJrMguaqW3sUHSLBo+r71OqldHeuwIfyIGIROTym11GWH56rIXxd51nJuVDWMvTg7bwcjN/d61LdfsaOAgqAYSUPlJjjp67GHZP/vson3uPr//NgnAJ/4gtjwReB7IX8oBLhB5s8lU6dnfnsLbY3Rt+THNA= on_sucess: always on_failure: always on_start: never From c08b7bb1c51f2b8f3e3780e7564d786482d2d168 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 13:40:36 -0300 Subject: [PATCH 153/202] =?UTF-8?q?Testa=20Deploy=20com=20execu=C3=A7?= =?UTF-8?q?=C3=A3o=20dos=20testes=20desabilitada.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 291161d82..9f539c82f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ install: true - composer install - sudo mkdir /tmp/wordpress/wordpress-test/wp-content/uploads -script: phpunit +script: echo "Executa testes!" #phpunit before_deploy: - echo "Seção executada antes do deploy!" - openssl aes-256-cbc -K $encrypted_cb93ef43fcd2_key -iv $encrypted_cb93ef43fcd2_iv @@ -41,7 +41,7 @@ before_deploy: - ssh-add -l deploy: - provider: script - script: echo "Faz Deploy!"#ssh $ssh_user@$ssh_host "sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" + script: ssh $ssh_user@$ssh_host "sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" skip_cleanup: true on: branch: continuousintegration @@ -55,7 +55,6 @@ notifications: secure: WjgA4OIad0/Ai+x1TUd7KShXpaJco9E/MfI6DWJFnBUF5JLKOxymTGbR82wspmnEwzXGWn++co1wNJh20pWobaIToL/2OpBd7xo5MHglNobH4cidmSIDPOQM8ItqBneRjayhXtfShRqQDNCk1D3d5KDUacXXeCX+GLdRuwdc/YuG7Zh3y1KrF6l10cwD/5JOJECwwMbqeLOezvzGi8ITL6pqnEEeNTb0Zr+K2Ru91RBOars4TLK3f5CmX4XxA4oQSMsrHKzTO2OZLua5CRwcBwKmtSqr0Z/W+RrXu2TLxvHYJ39t9uwssI3HmGoB/uNcahBTcE0Vk/phi3nfFO8KUGNqp3xLgUsF/xlb+WiIip2xOf9jq+XNGWwIVB2vWqiQppm58h57LgDNTF21XJOtfVPEyf9Em+VSfNgACq47u4kktgqgZ47xNEBZuv1s3as8BcgdQH78hF+qguhhHJH6RgyHt+GYAq2uRLF8z3IM8hfKpb5mA9jD3UfW3pXEtKF9K+XqtNycX8KxJ2ldEJrMguaqW3sUHSLBo+r71OqldHeuwIfyIGIROTym11GWH56rIXxd51nJuVDWMvTg7bwcjN/d61LdfsaOAgqAYSUPlJjjp67GHZP/vson3uPr//NgnAJ/4gtjwReB7IX8oBLhB5s8lU6dnfnsLbY3Rt+THNA= on_sucess: always on_failure: always - on_start: never email: on_success: never on_failure: always From c7c0a785614e905bc6a484d66920a13ebf3e491a Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 13:43:25 -0300 Subject: [PATCH 154/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9f539c82f..4407d3832 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ before_deploy: - ssh-add -l deploy: - provider: script - script: ssh $ssh_user@$ssh_host "sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" + script: sudo ssh $ssh_user@$ssh_host "sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" skip_cleanup: true on: branch: continuousintegration From b7ef47f07977626afa629344f415cb2468889500 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 13:46:28 -0300 Subject: [PATCH 155/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4407d3832..83ca7e764 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ before_deploy: - ssh-add -l deploy: - provider: script - script: sudo ssh $ssh_user@$ssh_host "sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" + script: ssh $ssh_user@$ssh_host " sudo sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" skip_cleanup: true on: branch: continuousintegration From 60e18796fd8776edce490a503c282154643fa5a6 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Tue, 5 Jun 2018 14:00:02 -0300 Subject: [PATCH 156/202] Fixes Thumbnail not disabling in custom view modes. --- src/admin/pages/lists/items-page.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/admin/pages/lists/items-page.vue b/src/admin/pages/lists/items-page.vue index fba000fa3..4a63fa8f9 100644 --- a/src/admin/pages/lists/items-page.vue +++ b/src/admin/pages/lists/items-page.vue @@ -465,11 +465,15 @@ } } } + let thumbnailField = this.localTableFields.find(field => field.slug == 'thumbnail'); + let creationDateField = this.localTableFields.find(field => field.slug == 'creation_date'); + let authorNameField = this.localTableFields.find(field => field.slug == 'author_name'); + this.$eventBusSearch.addFetchOnly({ - '0': 'thumbnail', + '0': thumbnailField.display ? 'thumbnail' : null, 'meta': fetchOnlyFieldIds, - '1': 'creation_date', - '2': 'author_name' + '1': creationDateField.display ? 'creation_date' : null, + '2': authorNameField.display ? 'author_name': null }); this.$refs.displayedFieldsDropdown.toggle(); }, From b5726a3df1d0e97e4519d945cadd693b19faae0a Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 14:41:30 -0300 Subject: [PATCH 157/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 83ca7e764..613464077 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ before_deploy: - ssh-add -l deploy: - provider: script - script: ssh $ssh_user@$ssh_host " sudo sh /home/l3p/atualiza_git/atualiza_novo_tainacan.sh" + script: ssh $ssh_user@$ssh_host "$script_deploy_tainacan" skip_cleanup: true on: branch: continuousintegration From da85dccd60e79238265d6ddc829b5a11d270785c Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Tue, 5 Jun 2018 14:45:07 -0300 Subject: [PATCH 158/202] Removes buggy call to field.field_type_options in itemsList. Fixes css for collection search button and actions cell. --- src/admin/components/lists/items-list.vue | 2 - src/admin/pages/lists/items-page.vue | 65 +++++++++++++---------- src/admin/scss/_tables.scss | 4 +- src/admin/theme-items-list.vue | 6 --- 4 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/admin/components/lists/items-list.vue b/src/admin/components/lists/items-list.vue index 0d887c83a..09bb9b932 100644 --- a/src/admin/components/lists/items-list.vue +++ b/src/admin/components/lists/items-list.vue @@ -84,8 +84,6 @@ v-for="(column, index) in tableFields" v-if="column.display" :label="column.name" - :aria-label="(column.field != 'row_thumbnail' && column.field != 'row_creation' && column.field != 'row_author') - ? column.name + '' + (item.metadata ? item.metadata[column.slug].value_as_string : '') : ''" class="column-default-width" :class="{ 'thumbnail-cell': column.field == 'row_thumbnail', diff --git a/src/admin/pages/lists/items-page.vue b/src/admin/pages/lists/items-page.vue index 4a63fa8f9..17e5ccfcc 100644 --- a/src/admin/pages/lists/items-page.vue +++ b/src/admin/pages/lists/items-page.vue @@ -20,30 +20,23 @@ :is-full-page="false" :active.sync="isLoadingFilters"/> - -
+
+
-
- -

- -

- + class="input is-small" + :placeholder="$i18n.get('instruction_search')" + type="search" + autocomplete="on" + :value="searchQuery" + @input="futureSearchQuery = $event.target.value" + @keyup.enter="updateSearch()"> + + + +
+
{{ $i18n.get('advanced_search') }} @@ -649,12 +642,26 @@ margin-top: 48px; } - #collection-search-button { - border-radius: 0 !important; - padding: 0 8px !important; - border-color: $tainacan-input-background; - &:focus, &:active { - border-color: none !important; + .search-area { + display: flex; + align-items: center; + margin-right: 36px; + + .control { + input { + height: 27px; + font-size: 11px; + color: $gray-light; + width: 160px; + } + .icon { + pointer-events: all; + cursor: pointer; + color: $tertiary; + height: 27px; + font-size: 18px; + } + margin-bottom: 5px; } } diff --git a/src/admin/scss/_tables.scss b/src/admin/scss/_tables.scss index f00fdfaee..eca4e120a 100644 --- a/src/admin/scss/_tables.scss +++ b/src/admin/scss/_tables.scss @@ -172,14 +172,13 @@ width: 80px; .actions-container { - visibility: hidden; display: flex; position: relative; padding: 0; height: 100%; width: 80px; z-index: 9; - background-color: transparent; + background-color: white; float: right; } @@ -206,7 +205,6 @@ } .actions-cell { .actions-container { - visibility: visible; background: $tainacan-input-background !important; } diff --git a/src/admin/theme-items-list.vue b/src/admin/theme-items-list.vue index 149f09cc0..2ff97cfb6 100644 --- a/src/admin/theme-items-list.vue +++ b/src/admin/theme-items-list.vue @@ -96,12 +96,6 @@ export default { line-height: 20px !important; font-size: 14px !important; } - #collection-search-button { - border: 1px solid $secondary !important; - height: 32px !important; - background-color: $secondary; - color: white; - } .input, .textarea { font-size: 14px; border: none; From a30fbec7b507a687f99870db26d4472ba04f8164 Mon Sep 17 00:00:00 2001 From: walisonjose Date: Tue, 5 Jun 2018 14:46:35 -0300 Subject: [PATCH 159/202] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 613464077..60ad69627 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ before_deploy: - ssh-add -l deploy: - provider: script - script: ssh $ssh_user@$ssh_host "$script_deploy_tainacan" + script: ssh $ssh_user@$ssh_host $script_deploy_tainacan skip_cleanup: true on: branch: continuousintegration From f201edb9411c4fcbf5a52bd5df1b1ee53429d9e8 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Tue, 5 Jun 2018 17:25:18 -0300 Subject: [PATCH 160/202] Adds Cards view mode to Admin Panel. Still needs details adjustments. --- src/admin/components/lists/items-list.vue | 92 ++++++++++++++++++- src/admin/pages/lists/items-page.vue | 44 ++++++++- .../scss/_dropdown-and-autocomplete.scss | 1 + src/admin/scss/_view-mode-cards.scss | 81 ++++++++++++++++ src/admin/tainacan-admin-i18n.php | 3 + 5 files changed, 215 insertions(+), 6 deletions(-) create mode 100644 src/admin/scss/_view-mode-cards.scss diff --git a/src/admin/components/lists/items-list.vue b/src/admin/components/lists/items-list.vue index 09bb9b932..60b612293 100644 --- a/src/admin/components/lists/items-list.vue +++ b/src/admin/components/lists/items-list.vue @@ -35,7 +35,93 @@
- + + +
+ +
+
+
+ + +
+ +
+ + + + + + + + +
+ + + + + +
+
+
+
+
+ + +
@@ -180,7 +266,8 @@ export default { tableFields: Array, items: Array, isLoading: false, - isOnTrash: false + isOnTrash: false, + viewMode: 'table' }, mounted() { this.selectedItems = []; @@ -309,6 +396,7 @@ export default { \ No newline at end of file diff --git a/src/admin/components/navigation/tainacan-header.vue b/src/admin/components/navigation/tainacan-header.vue index 5fa34bcb6..ea592eae5 100644 --- a/src/admin/components/navigation/tainacan-header.vue +++ b/src/admin/components/navigation/tainacan-header.vue @@ -20,7 +20,7 @@
@@ -28,7 +28,7 @@
- {{ $i18n.get('advanced_search') }} + {{ $i18n.get('advanced_search') }} - -