Merge branch 'develop' of https://github.com/tainacan/tainacan into develop
This commit is contained in:
commit
4f4d048e4e
|
@ -2,17 +2,15 @@
|
||||||
<div id="tainacan-admin-app" class="columns is-fullheight">
|
<div id="tainacan-admin-app" class="columns is-fullheight">
|
||||||
<nav id="primary-menu" role="navigation" aria-label="main navigation" class="column is-2 is-sidebar-menu">
|
<nav id="primary-menu" role="navigation" aria-label="main navigation" class="column is-2 is-sidebar-menu">
|
||||||
<aside class="menu">
|
<aside class="menu">
|
||||||
<router-link to="/">
|
<h1 class="menu-level-title">{{ $i18n.get('repository') }}</h1>
|
||||||
<img :src="logoHeader" alt="Tainacan Admin" height="32">
|
|
||||||
</router-link>
|
|
||||||
<ul class="menu-list">
|
<ul class="menu-list">
|
||||||
<li><router-link tag="a" to="/collections">{{ $i18n.getString('menu', 'collections')}}</router-link></li>
|
<li><router-link tag="a" to="/collections">{{ $i18n.get('collections')}}</router-link></li>
|
||||||
<li><router-link tag="a" to="/items">{{ $i18n.getString('menu', 'items')}}</router-link></li>
|
<li><router-link tag="a" to="/items">{{ $i18n.get('items')}}</router-link></li>
|
||||||
<li><router-link tag="a" to="/fields">{{ $i18n.getString('menu', 'fields')}}</router-link></li>
|
<li><router-link tag="a" to="/fields">{{ $i18n.get('fields')}}</router-link></li>
|
||||||
<li><router-link tag="a" to="/filters">{{ $i18n.getString('menu', 'filters')}}</router-link></li>
|
<li><router-link tag="a" to="/filters">{{ $i18n.get('filters')}}</router-link></li>
|
||||||
<li><router-link tag="a" to="/categories">{{ $i18n.getString('menu', 'categories')}}</router-link></li>
|
<li><router-link tag="a" to="/categories">{{ $i18n.get('categories')}}</router-link></li>
|
||||||
<li><router-link tag="a" to="/events">{{ $i18n.getString('menu', 'events')}}</router-link></li>
|
<li><router-link tag="a" to="/events">{{ $i18n.get('events')}}</router-link></li>
|
||||||
<li><a class="navbar-item" :href="wordpressAdmin">Admin do Wordpress</a></li>
|
<li><a class="navbar-item" :href="wordpressAdmin">Wordpress</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -40,6 +38,8 @@
|
||||||
|
|
||||||
.is-fullheight {
|
.is-fullheight {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
margin-top: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#primary-menu {
|
#primary-menu {
|
||||||
|
@ -51,6 +51,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.is-main-content {
|
||||||
|
padding-bottom: 0px;
|
||||||
|
padding-top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
#secondary-menu {
|
#secondary-menu {
|
||||||
background-color: $secondary;
|
background-color: $secondary;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
@page-change="onPageChange">
|
@page-change="onPageChange">
|
||||||
<template slot-scope="props">
|
<template slot-scope="props">
|
||||||
|
|
||||||
<b-table-column field="featured_image" width="55" :sortable="false">
|
<b-table-column field="featured_image" width="55" sortable="{{ false }}">
|
||||||
<template v-if="props.row.featured_image" slot-scope="scope">
|
<template v-if="props.row.featured_image" slot-scope="scope">
|
||||||
<img class="table-thumb" :src="`${props.row.featured_image}`"/>
|
<img class="table-thumb" :src="`${props.row.featured_image}`"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB |
|
@ -38,16 +38,13 @@ Vue.component('tainacan-relationship', Relationship);
|
||||||
Vue.component('tainacan-form-item', TaincanFormItem);
|
Vue.component('tainacan-form-item', TaincanFormItem);
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// I18N DIRECTIVE
|
// I18N PLUGIN
|
||||||
const I18NPlugin = {};
|
const I18NPlugin = {};
|
||||||
I18NPlugin.install = function (Vue, options = {}) {
|
I18NPlugin.install = function (Vue, options = {}) {
|
||||||
|
|
||||||
Vue.prototype.$i18n = {
|
Vue.prototype.$i18n = {
|
||||||
getString: function (component, key) {
|
get: function (key) {
|
||||||
if (wp_settings.i18n[component] == null || wp_settings.i18n[component] == undefined)
|
let string = wp_settings.i18n[key];
|
||||||
return "ERROR: Invalid i18n component!"
|
|
||||||
|
|
||||||
let string = wp_settings.i18n[component][key];
|
|
||||||
return (string != undefined && string != null && string != '' ) ? string : "ERROR: Invalid i18n key!";
|
return (string != undefined && string != null && string != '' ) ? string : "ERROR: Invalid i18n key!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
<nav id="secondary-menu" role="navigation" aria-label="secondary navigation" class="column is-2 is-sidebar-menu">
|
<nav id="secondary-menu" role="navigation" aria-label="secondary navigation" class="column is-2 is-sidebar-menu">
|
||||||
<aside class="menu">
|
<aside class="menu">
|
||||||
<ul class="menu-list">
|
<ul class="menu-list">
|
||||||
<li><router-link tag="a" to="">Itens</router-link></li>
|
<li><router-link tag="a" to="">{{ $i18n.get('items')}}</router-link></li>
|
||||||
<li><router-link tag="a" to="">Editar</router-link></li>
|
<li><router-link tag="a" to="">{{ $i18n.get('edit')}}</router-link></li>
|
||||||
<li><router-link tag="a" to="">Campos</router-link></li>
|
<li><router-link tag="a" to="">{{ $i18n.get('fields')}}</router-link></li>
|
||||||
<li><router-link tag="a" to="">Filtros</router-link></li>
|
<li><router-link tag="a" to="">{{ $i18n.get('filters')}}</router-link></li>
|
||||||
<li><router-link tag="a" to="">Atividades</router-link></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -1,26 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
// Tainacan common terms
|
||||||
|
'repository' => __('Repository', 'tainacan'),
|
||||||
|
'collections' => __('Collections', 'tainacan'),
|
||||||
|
'items' => __('Items', 'tainacan'),
|
||||||
|
'fields' => __('Fields', 'tainacan'),
|
||||||
|
'filters' => __('Filters', 'tainacan'),
|
||||||
|
'categories' => __('Categories', 'tainacan'),
|
||||||
|
'events' => __('Events', 'tainacan'),
|
||||||
|
'collection' => __('Collection', 'tainacan'),
|
||||||
|
'item' => __('Item', 'tainacan'),
|
||||||
|
'field' => __('Field', 'tainacan'),
|
||||||
|
'filter' => __('Filter', 'tainacan'),
|
||||||
|
'category' => __('Categorie', 'tainacan'),
|
||||||
|
'event' => __('Event', 'tainacan'),
|
||||||
|
|
||||||
'menu' => [
|
// Actions
|
||||||
'collections' => __('Collections', 'tainacan'),
|
'edit' => __('Edit', 'tainacan'),
|
||||||
'items' => __('Items', 'tainacan'),
|
'new' => __('New', 'tainacan'),
|
||||||
'fields' => __('Fields', 'tainacan'),
|
|
||||||
'filters' => __('Filters', 'tainacan'),
|
|
||||||
'categories' => __('Categories', 'tainacan'),
|
|
||||||
'events' => __('Events', 'tainacan')
|
|
||||||
],
|
|
||||||
|
|
||||||
'collection_page' => [
|
|
||||||
'title' => __('Collections', 'tainacan'),
|
|
||||||
'subtitle' => __('Browse Collections', 'tainacan'),
|
|
||||||
],
|
|
||||||
|
|
||||||
'Items_page' => [
|
|
||||||
'title' => __('Items', 'tainacan'),
|
|
||||||
'subtitle' => __('Browse Items', 'tainacan'),
|
|
||||||
]
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -5,17 +5,31 @@ use Tainacan;
|
||||||
|
|
||||||
class CSV extends Importer {
|
class CSV extends Importer {
|
||||||
|
|
||||||
public $delimiter;
|
public $delimiter = ',';
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return string $delimiter value that divides each column
|
||||||
|
*/
|
||||||
|
public function get_delimiter(){
|
||||||
|
return $this->delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function set_delimiter( $delimiter ){
|
||||||
|
$this->delimiter = $delimiter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
public function get_fields_source(){
|
public function get_fields_source(){
|
||||||
// TODO: Implement get_fields_source() method.
|
$file = new \SplFileObject( $this->tmp_file, 'r' );
|
||||||
|
$file->seek(0 );
|
||||||
|
return $file->fgetcsv( $this->get_delimiter() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,4 +45,16 @@ class CSV extends Importer {
|
||||||
public function get_options(){
|
public function get_options(){
|
||||||
// TODO: Implement get_options() method.
|
// TODO: Implement get_options() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get_total_items(){
|
||||||
|
if( isset( $this->total_items ) ){
|
||||||
|
return $this->total_items;
|
||||||
|
} else {
|
||||||
|
$file = new \SplFileObject( $this->tmp_file, 'r' );
|
||||||
|
$file->seek(PHP_INT_MAX);
|
||||||
|
// -1 removing header
|
||||||
|
return $this->total_items = $file->key() - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -27,6 +27,14 @@ abstract class Importer {
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_mapping(){
|
||||||
|
return $this->mapping;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Tainacan\Entities\Collection $collection
|
* @param Tainacan\Entities\Collection $collection
|
||||||
*/
|
*/
|
||||||
|
@ -35,6 +43,8 @@ abstract class Importer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* save an associative array with tainacan field id and field from source
|
||||||
|
*
|
||||||
* @param array $mapping Mapping importer-fields
|
* @param array $mapping Mapping importer-fields
|
||||||
*/
|
*/
|
||||||
public function set_mapping( $mapping ){
|
public function set_mapping( $mapping ){
|
||||||
|
@ -48,8 +58,7 @@ abstract class Importer {
|
||||||
public function set_file( $file ){
|
public function set_file( $file ){
|
||||||
$new_file = $this->upload_file( $file );
|
$new_file = $this->upload_file( $file );
|
||||||
if ( is_numeric( $new_file ) ) {
|
if ( is_numeric( $new_file ) ) {
|
||||||
$attach = get_post($new_file);
|
$this->tmp_file = get_attached_file( $new_file );
|
||||||
$this->tmp_file = $attach->guid;
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -85,9 +94,18 @@ abstract class Importer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function get_collection_fields(){
|
||||||
|
return $this->collection;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the fields of file/url to allow mapping
|
* get the fields of file/url to allow mapping
|
||||||
* should returns an array
|
* should returns an array
|
||||||
|
*
|
||||||
|
* @return array $fields_source the fields from the source
|
||||||
*/
|
*/
|
||||||
abstract public function get_fields_source();
|
abstract public function get_fields_source();
|
||||||
|
|
||||||
|
@ -101,6 +119,13 @@ abstract class Importer {
|
||||||
*/
|
*/
|
||||||
abstract public function get_options();
|
abstract public function get_options();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return the all items found
|
||||||
|
*
|
||||||
|
* @return int Total of items
|
||||||
|
*/
|
||||||
|
abstract public function get_total_items();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $start
|
* @param $start
|
||||||
* @param $end
|
* @param $end
|
||||||
|
|
|
@ -36,7 +36,9 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
||||||
/**
|
/**
|
||||||
* @group importer
|
* @group importer
|
||||||
*/
|
*/
|
||||||
public function test_file_import_csv () {
|
public function test_file_csv () {
|
||||||
|
global $Tainacan_Fields;
|
||||||
|
|
||||||
$csv_importer = new Importer\CSV();
|
$csv_importer = new Importer\CSV();
|
||||||
$id = $csv_importer->get_id();
|
$id = $csv_importer->get_id();
|
||||||
|
|
||||||
|
@ -65,8 +67,46 @@ class ImporterTests extends TAINACAN_UnitTestCase {
|
||||||
|
|
||||||
$_SESSION['tainacan_importer'][$id]->set_file( 'demosaved.csv' );
|
$_SESSION['tainacan_importer'][$id]->set_file( 'demosaved.csv' );
|
||||||
|
|
||||||
// here the session is init already
|
// file isset on importer
|
||||||
$this->assertTrue( isset( $_SESSION['tainacan_importer'][$id]->tmp_file ) );
|
$this->assertTrue( isset( $_SESSION['tainacan_importer'][$id]->tmp_file ) );
|
||||||
|
|
||||||
|
// count size of csv
|
||||||
|
$this->assertEquals( 5, $_SESSION['tainacan_importer'][$id]->get_total_items() );
|
||||||
|
|
||||||
|
// get fields to mapping
|
||||||
|
$headers = $_SESSION['tainacan_importer'][$id]->get_fields_source();
|
||||||
|
$this->assertEquals( $headers[4], 'Column 5' );
|
||||||
|
|
||||||
|
// inserting the collection
|
||||||
|
$collection = $this->tainacan_entity_factory->create_entity(
|
||||||
|
'collection',
|
||||||
|
array(
|
||||||
|
'name' => 'Other',
|
||||||
|
'description' => 'adasdasdsa',
|
||||||
|
'default_order' => 'DESC',
|
||||||
|
'status' => 'publish'
|
||||||
|
),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
// set the importer
|
||||||
|
$_SESSION['tainacan_importer'][$id]->set_collection( $collection );
|
||||||
|
|
||||||
|
// get collection fields to map
|
||||||
|
$fields = $Tainacan_Fields->fetch_by_collection( $collection, [], 'OBJECT' ) ;
|
||||||
|
|
||||||
|
//create a random mapping
|
||||||
|
$map = [];
|
||||||
|
foreach ( $fields as $index => $field ){
|
||||||
|
$map[$field->get_id()] = $headers[$index];
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the mapping
|
||||||
|
$_SESSION['tainacan_importer'][$id]->set_mapping( $map );
|
||||||
|
|
||||||
|
// check is equal
|
||||||
|
$this->assertEquals( $_SESSION['tainacan_importer'][$id]->get_mapping(), $map );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue