Merge branch 'develop' of https://github.com/tainacan/tainacan into develop

This commit is contained in:
weryques 2018-06-04 09:50:56 -03:00
commit bbbe56378e
21 changed files with 114 additions and 264 deletions

View File

@ -101,10 +101,10 @@
v-if="column.field !== 'row_thumbnail' &&
column.field !== 'row_actions' &&
column.field !== 'row_creation'"
:data="renderMetadata( item.metadata[column.slug] )"/> -->
:data="renderMetadata(item.metadata, column)"/> -->
<p
v-tooltip="{
content: renderMetadata( item.metadata[column.slug] ),
content: renderMetadata(item.metadata, column),
html: true,
autoHide: false,
placement: 'auto-start'
@ -114,7 +114,7 @@
column.field !== 'row_actions' &&
column.field !== 'row_creation' &&
column.field !== 'row_author'"
v-html="renderMetadata( item.metadata[column.slug] )"/>
v-html="renderMetadata(item.metadata, column)"/>
<span v-if="column.field == 'row_thumbnail'">
<img
@ -284,7 +284,9 @@ export default {
goToItemEditPage(itemId) {
this.$router.push(this.$routerHelper.getItemEditPath(this.collectionId, itemId));
},
renderMetadata(metadata) {
renderMetadata(itemMetadata, column) {
let metadata = itemMetadata[column.slug] != undefined ? itemMetadata[column.slug] : false;
if (!metadata) {
return '';

View File

@ -102,6 +102,9 @@
max-width: $side-menu-width;
z-index: 99;
.menu {
padding-top: 10px;
}
.separator {
height: 2px;
background-color: $separator-color;

View File

@ -268,7 +268,6 @@ export default {
}
.level-left {
margin-left: 5px;
.level-item {
display: inline-block;
}
@ -348,9 +347,6 @@ export default {
.level-left {
margin-left: 0px !important;
.level-item {
margin-left: 30px;
}
}
top: 206px;
margin-bottom: 0px !important;

View File

@ -41,7 +41,7 @@ import draggable from 'vuedraggable'
import store from '../../js/store/store'
import router from './router'
import eventBusSearch from '../../js/event-bus-search';
import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin } from './utilities';
import { I18NPlugin, UserPrefsPlugin, RouterHelperPlugin, ConsolePlugin, UserCapabilitiesPlugin } from './utilities';
import VueMask from 'v-mask';
// Configure and Register Plugins
@ -50,6 +50,7 @@ Vue.use(VTooltip)
Vue.use(I18NPlugin);
Vue.use(UserPrefsPlugin);
Vue.use(RouterHelperPlugin);
Vue.use(UserCapabilitiesPlugin);
Vue.use(ConsolePlugin, {visual: false});
Vue.use(VueMask);

View File

@ -254,8 +254,20 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
},
getEventEditPath(id) {
return '/events/' + id + '/edit';
}
}
}
}
// USER CAPABILITIES PLUGIN - Allows easy checking of user capabilities.
export const UserCapabilitiesPlugin = {};
UserCapabilitiesPlugin.install = function (Vue, options = {}) {
Vue.prototype.$userCaps = {
hasCapability(key) {
for (let i = 0; i < tainacan_plugin.user_caps.length; i++)
if (tainacan_plugin.user_caps[i] == key)
return true;
return false;
}
}
}

View File

@ -4,7 +4,7 @@
<tainacan-title />
<div
class="sub-header"
v-if="checkIfUserCanEdit()">
v-if="$userCaps.hasCapability('edit_tainacan-taxonomies')">
<div class="header-item">
<router-link
id="button-create-category"
@ -135,13 +135,6 @@
this.status = status;
this.loadCategories();
},
checkIfUserCanEdit() {
for (let capability of tainacan_plugin.user_caps) {
if (capability == 'edit_tainacan-taxonomies')
return true;
}
return false;
},
onChangeCategoriesPerPage(value) {
let prevValue = this.categoriesPerPage;
this.categoriesPerPage = value;
@ -205,7 +198,7 @@
padding-top: $page-small-top-padding;
padding-left: $page-side-padding;
padding-right: $page-side-padding;
border-bottom: 0.5px solid #ddd;
border-bottom: 1px solid #ddd;
.header-item {
display: inline-block;

View File

@ -3,7 +3,7 @@
<tainacan-title />
<div
class="sub-header"
v-if="checkIfUserCanEdit()">
v-if="$userCaps.hasCapability('edit_tainacan-collections')">
<div class="header-item">
<b-dropdown id="collection-creation-options-dropdown">
<button
@ -149,13 +149,6 @@ export default {
this.status = status;
this.loadCollections();
},
checkIfUserCanEdit() {
for (let capability of tainacan_plugin.user_caps) {
if (capability == 'edit_tainacan-collections')
return true;
}
return false;
},
onChangeCollectionsPerPage(value) {
let prevValue = this.collectionsPerPage;
this.collectionsPerPage = value;
@ -216,7 +209,7 @@ export default {
padding-top: $page-small-top-padding;
padding-left: $page-side-padding;
padding-right: $page-side-padding;
border-bottom: 0.5px solid #ddd;
border-bottom: 1px solid #ddd;
.header-item {
display: inline-block;

View File

@ -167,7 +167,7 @@
padding-top: $page-small-top-padding;
padding-left: $page-small-side-padding;
padding-right: $page-small-side-padding;
border-bottom: 0.5px solid #ddd;
border-bottom: 1px solid #ddd;
.header-item {
display: inline-block;

View File

@ -14,7 +14,8 @@
<!-- Side bar with search and filters -->
<aside
v-show="!isFiltersMenuCompressed"
class="filters-menu">
class="filters-menu"
:class="{ 'tainacan-form': isOnTheme }">
<b-loading
:is-full-page="false"
:active.sync="isLoadingFilters"/>
@ -76,11 +77,12 @@
<div class="content has-text-gray has-text-centered">
<p>
<b-icon
icon="filter-outline"
icon="filter"
size="is-large"/>
</p>
<p>{{ $i18n.get('info_there_is_no_filter' ) }}</p>
<router-link
v-if="!isOnTheme"
id="button-create-filter"
:to="isRepositoryLevel ? $routerHelper.getNewFilterPath() : $routerHelper.getNewCollectionFilterPath(collectionId)"
tag="button"
@ -468,7 +470,7 @@
this.fetchFilters({
collectionId: this.collectionId,
isRepositoryLevel: this.isRepositoryLevel,
isContextEdit: true,
isContextEdit: !this.isOnTheme,
includeDisabled: 'no',
})
.then(() => this.isLoadingFilters = false)
@ -480,7 +482,7 @@
this.fetchFields({
collectionId: this.collectionId,
isRepositoryLevel: this.isRepositoryLevel,
isContextEdit: false
isContextEdit: !this.isOnTheme
})
.then(() => {
@ -498,11 +500,12 @@
for (let field of this.fields) {
if (field.display !== 'never') {
let display = true;
let display;
if (field.display === 'no') {
if (field.display == 'no')
display = false;
}
else if (field.display == 'yes')
display = true;
this.tableFields.push(
{
@ -515,7 +518,8 @@
display: display
}
);
fetchOnlyFieldIds.push(field.id);
if (display)
fetchOnlyFieldIds.push(field.id);
}
}
@ -620,6 +624,7 @@
padding: $page-small-side-padding;
float: left;
overflow-y: auto;
overflow-x: hidden;
visibility: visible;
display: block;
transition: visibility ease 0.5s, display ease 0.5s;
@ -676,22 +681,14 @@
.search-control {
min-height: $subheader-height;
height: $subheader-height;
height: auto;
padding-top: $page-small-top-padding;
padding-left: $page-side-padding;
padding-right: $page-side-padding;
border-bottom: 0.5px solid #ddd;
display: flex;
justify-content: space-between;
@media screen and (max-width: 769px) {
height: 60px;
margin-top: 0;
.search-control-item {
padding-right: 0.5em;
}
}
flex-wrap: wrap;
}
.search-control-item {
@ -752,6 +749,7 @@
.table-container {
padding-left: 8.333333%;
padding-right: 8.333333%;
min-height: 200px;
//height: calc(100% - 82px);
}

View File

@ -14,16 +14,18 @@
}
}
.dropdown-menu {
padding: 0;
border-radius: 0px;
.dropdown-content {
padding: 0;
border-radius: 0px !important;
.dropdown-item {
padding: 0.375rem 1rem;
label { margin-bottom: 0; }
&.control { font-size: 13px !important; }
.b-checkbox { width: 100% };
&:hover {
background-color: $primary-lighter;
}
.is-small {
color: gray;
}
&:hover { background-color: $primary-lighter; }
.is-small { color: gray; }
}
}
}

View File

@ -5,3 +5,4 @@
@import "../../../node_modules/bulma/sass/elements/icon.sass"
@import "../../../node_modules/bulma/sass/elements/tag.sass"
@import "../../../node_modules/bulma/sass/components/tabs.sass"
@import "../../../node_modules/bulma/sass/elements/button.sass"

View File

@ -14,6 +14,8 @@ export default {
<style lang="scss">
@import "../admin/scss/_variables.scss";
// Bulma imports
@import "./scss/theme-basics.sass";
@ -28,9 +30,11 @@ export default {
@import "../../node_modules/buefy/src/scss/components/_dropdown.scss";
// Tainacan imports
@import "../admin/scss/_variables.scss";
@import "../admin/scss/_tables.scss";
@import "../admin/scss/_selects.scss";
@import "../admin/scss/_dropdown-and-autocomplete.scss";
@import "../admin/scss/_tooltips.scss";
@import "../admin/scss/_tainacan-form.scss";
.theme-items-list {
position: relative;
@ -55,11 +59,8 @@ export default {
margin-top: 0px;
margin-bottom: 0px;
display: inline-flex;
color: #1d1d1d;
font-size: 1.0em;
font-weight: normal;
cursor: pointer;
background-color: white;
&.is-secondary:hover, &.is-secondary:focus {
background: $secondary !important;
@ -96,201 +97,30 @@ export default {
font-size: 14px !important;
}
#collection-search-button {
height: 25px !important;
border: 1px solid $secondary !important;
height: 32px !important;
background-color: $secondary;
color: white;
}
.select {
padding-top: 0px !important;
select {
border: none;
border-radius: 1px !important;
font-weight: normal;
font-size: 14px !important;
height: 30px !important;
padding: 2px 25px 2px 15px!important;
margin-top: 0px !important;
margin-bottom: 0px !important;
color: $tainacan-input-color;
option:checked, option:hover {
background-color: $primary-lighter !important;
}
&:focus, &:active {
box-shadow: none !important;
text-decoration: none !important;
}
}
&:not(.is-multiple)::after {
content: "\F35D" !important;
font: normal normal normal 24px/1 "Material Design Icons" !important;
border: none !important;
transform: none !important;
margin-top: -15px !important;
right: 10px !important;
color: $primary;
display: flex !important;
align-items: initial;
}
.input, .textarea {
font-size: 14px;
border: none;
border-radius: 1px !important;
box-shadow: none !important;
&:focus, &:active {
box-shadow: none !important;
background-color: white;
border: 1px solid $tainacan-input-background !important;
}
}
.dropdown {
display: inline-flex;
position: relative;
vertical-align: top;
}
.dropdown, .autocomplete {
.dropdown-trigger{
.button {
border: none;
.icon {
color: $secondary;
align-items: start;
}
}
.button.is-primary, .button.is-secondary, .button.is-success {
.icon {
color: $white;
}
}
}
.dropdown-menu {
display: block;
.dropdown-content {
font-size: 13px !important;
border-radius: 0px !important;
.dropdown-item {
a {
color: $tainacan-input-color !important;
}
.b-checkbox { width: 100% };
&:hover {
background-color: $primary-lighter;
}
.is-small {
color: gray;
}
}
}
}
}
.taginput-container {
padding: 0 !important;
background-color: white !important;
&:focus, &:active {
border: none !important;
}
.input { margin-bottom: 0px !important; }
.input.has-selected, .input:focus, .input:active {
background-color: white;
border: 1px solid $tainacan-input-background !important;
}
.tag {
background: white;
padding-right: 0;
padding-left: 0.5em;
&.is-delete {
color: $gray-light;
&::after {
height: 30% !important;
width: 1px !important;
}
&::before {
width: 30% !important;
height: 1px !important;
}
&:hover, &:focus {
background-color: white;
color: black;
}
}
}
}
.selected-list-box {
padding: 4px 0px;
border: 1px solid $tainacan-input-background;
background-color: white;
display: flex;
.tags {
margin-right: 8px;
}
.tag {
background: white;
padding-right: 0;
padding-left: 0.5em;
&.is-delete {
color: $gray-light;
&::after {
height: 30% !important;
width: 1px !important;
}
&::before {
width: 30% !important;
height: 1px !important;
}
&:hover, &:focus {
background-color: white;
color: black;
}
}
}
}
.switch {
input[type="checkbox"] + .check {
background-color: $gray-light;
border: 2px solid $gray-light;
width: 2.7em;
height: 1.7em;
&::before {
background-color: white;
box-shadow: none;
}
}
&:hover input[type="checkbox"]:checked + .check {
background-color: $primary-light;
}
input[type="checkbox"]:checked + .check {
border: 2px solid $secondary;
background-color: transparent;
&::before {
background-color: $secondary;
transform: translate3d(78%, 0, 0);
}
}
&:hover input[type="checkbox"] + .check {
background-color: $gray-light;
}
&:focus input[type="checkbox"] + .check,
&:focus input[type="checkbox"]:checked + .check {
box-shadow: none;
}
&.is-small {
font-size: 9px;
input[type="checkbox"] + .check {
border: 1.5px solid $gray-light;
width: 2.55em;
height: 1.7em;
&::before {
width: 1.0em;
height: 1.0em;
}
}
input[type="checkbox"]:checked + .check {
border: 1.5px solid $secondary;
&::before {
transform: translate3d(84%, 0, 0);
}
}
}
.dropdown-menu {
display: block;
}
.b-checkbox.checkbox {
@ -459,10 +289,13 @@ export default {
.filters-menu {
height: auto;
min-width: $filter-menu-width;
background-color: unset;
border-right: 1px solid $tainacan-input-background;
}
#items-list-area {
width: 100%;
overflow-y: unset;
}
}

View File

@ -48,7 +48,10 @@ class Core_Description extends Field_Type {
*
* @param TainacanEntitiesItem_Metadata_Entity $item_metadata
* @return bool Valid or not
*/
*
* Quarantine - Core metadata should be validated as any other metadata
* and item title is no longer mandatory
public function validate(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$item = $item_metadata->get_item();
@ -61,6 +64,8 @@ class Core_Description extends Field_Type {
return $item->validate_prop('description');
}
*/
public function validate_options( Field $field ) {

View File

@ -49,7 +49,10 @@ class Core_Title extends Field_Type {
*
* @param TainacanEntitiesItem_Metadata_Entity $item_metadata
* @return bool Valid or not
*/
*
* Quarantine - Core metadata should be validated as any other metadata
* and item title is no longer mandatory
public function validate(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$item = $item_metadata->get_item();
@ -62,6 +65,7 @@ class Core_Title extends Field_Type {
return $item->validate_prop('title');
}
*/
public function validate_options( Field $field ) {

View File

@ -5,10 +5,10 @@
:type="fieldTypeMessage">
<span
class="collapse-handle"
@click="$emit('changeCollapse', !isCollapsed)">
@click="$emit('changeCollapse', fieldTypeMessage != 'is-danger' ? !isCollapsed : true)">
<b-icon
type="is-secondary"
:icon="isCollapsed ? 'menu-down' : 'menu-right'" />
:icon="isCollapsed || fieldTypeMessage == 'is-danger' ? 'menu-down' : 'menu-right'" />
<label class="label">{{ field.field.name }}</label>
<span
v-if="field.field.required == 'yes'"
@ -20,7 +20,7 @@
:message="field.field.description"/>
</span>
<div
v-show="isCollapsed"
v-show="isCollapsed || fieldTypeMessage == 'is-danger'"
v-if="isTextInputComponent( field.field.field_type_object.component )">
<component
:id="field.field.field_type_object.component + '-' + field.field.slug"
@ -87,19 +87,19 @@
let msg = '';
let errors = eventBus.getErrors(this.field.field.id);
if ( errors) {
this.setFieldTypeMessage('is-danger');
for (let error of errors) {
for (let index of Object.keys(error)) {
//this.$console.log(index);
// this.$console.log(index);
msg += error[index] + '\n';
}
}
} else {
this.setFieldTypeMessage('');
}
return msg;
}
},
@ -133,8 +133,6 @@
},
setFieldTypeMessage( message ){
this.fieldTypeMessage = message;
if (message != '')
this.$emit('changeCollapse', true);
}
}
}

View File

@ -266,6 +266,7 @@ class Collections extends Repository {
$Tainacan_Fields->register_core_fields( $new_collection );
$collection->register_collection_item_post_type();
flush_rewrite_rules(false); // needed to activate items post type archive url
$this->update_moderators( $new_collection );
return $new_collection;

View File

@ -36,7 +36,7 @@ class Items extends Repository {
'type' => 'string',
'description' => __( 'Title of the item', 'tainacan' ),
'on_error' => __( 'The title should be a text value and not empty', 'tainacan' ),
'validation' => v::stringType()->notEmpty(),
//'validation' => v::stringType()->notEmpty(),
],
'status' => [
'map' => 'post_status',

View File

@ -765,9 +765,13 @@ class Old_Tainacan extends Importer
*/
public function get_total_items_from_source()
{
if(!isset($this->tmp_file)){
return 0;
}
$file = new \SplFileObject( $this->tmp_file, 'r' );
$file_content = unserialize($file->fread($file->getSize()));
return $this->total_items = $file_content->found_items;
}
}
}

View File

@ -36,6 +36,7 @@ export const eventBus = new Vue({
},
updateValue(data){
if ( data.item_id ){
let values = ( Array.isArray( data.values[0] ) ) ? data.values[0] : data.values ;
const promisse = this.$store.dispatch('item/updateMetadata',
{ item_id: data.item_id, field_id: data.field_id, values: values });
@ -62,7 +63,7 @@ export const eventBus = new Vue({
});
}
},
getErrors(field_id){
getErrors(field_id) {
let error = this.errors.find( errorItem => errorItem.field_id == field_id );
return ( error ) ? error.errors : false
},

View File

@ -21,6 +21,7 @@ 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 => {

View File

@ -5,6 +5,7 @@ use Tainacan\Importer;
/**
* Class Importer
*
* @group importer
* @package Test_Tainacan
*/
@ -45,8 +46,9 @@ class ImporterTests extends TAINACAN_UnitTestCase {
//}
//$_SESSION['tainacan_importer'][$id]->set_file( './tests/attachment/json_old_tainacan.txt' );
$url = 'http://localhost/';
$url = 'http://localhost/wordpress_tainacan/';
$_SESSION['tainacan_importer'][$id]->set_url($url);
$_SESSION['tainacan_importer'][$id]->set_repository();
while (!$_SESSION['tainacan_importer'][$id]->is_finished())
{
@ -161,9 +163,9 @@ class ImporterTests extends TAINACAN_UnitTestCase {
$file_name = 'demosaved.csv';
$csv_importer = new Importer\CSV();
$id = $csv_importer->get_id();
$_SESSION['tainacan_importer'][$id]->set_items_per_step(2);
// open the file "demosaved.csv" for writing
$file = fopen($file_name, 'w');
@ -230,7 +232,7 @@ class ImporterTests extends TAINACAN_UnitTestCase {
$this->assertEquals( $_SESSION['tainacan_importer'][$id]->get_mapping(), $map );
//execute the process
$this->assertEquals(2, $_SESSION['tainacan_importer'][$id]->run(), 'first step should import 2 items');
$this->assertEquals(4, $_SESSION['tainacan_importer'][$id]->run(), 'second step should import 2 items');
$this->assertEquals(5, $_SESSION['tainacan_importer'][$id]->run(), 'third step should import 3 items');
@ -250,4 +252,4 @@ class ImporterTests extends TAINACAN_UnitTestCase {
$_SESSION['tainacan_importer'][$id]->fetch_from_remote( 'http://localhost/wordpress-test/wp-json' );
$this->assertTrue( isset( $_SESSION['tainacan_importer'][$id]->tmp_file ) );
}
}
}