merge src/classes/repositories/class-tainacan-fields.php

This commit is contained in:
Jacson Passold 2018-04-11 14:54:38 -03:00
commit 6356fb4705
132 changed files with 3357 additions and 1635 deletions

View File

@ -0,0 +1,107 @@
describe('Category test', function () {
beforeEach(() => {
cy.loginByUI()
})
it('clear DB', function(){
cy.clearDB()
})
context('CRUD Taxonomies', function(){
it('canceled create category', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/categories')
cy.location('hash').should('eq', '#/categories')
//cy.get('#button-category-creation').click()
cy.get('.button').click()
cy.location('hash').should('eq', '#/categories/new')
cy.get('#tainacan-text-name').type('Category canceled')
cy.get('#tainacan-text-description').type('description category canceled')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-cancel-category-creation').click()
cy.location('hash').should('eq', '#/categories/')
cy.get('td').should('not.contain', 'Book canceled')
})
// it('create category with status publish', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/categories')
// cy.location('hash').should('eq', '#/categories')
// //cy.get('#button-category-creation').click()
// cy.get('.button').click()
// cy.location('hash').should('eq', '#/categories/new')
// cy.get('#tainacan-text-name').type('Category publish')
// cy.get('#tainacan-text-description').type('description category publish')
// cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
// cy.get('#button-submit-category-creation').click()
// cy.location('hash').should('eq', '#/categories/')
// cy.get('td').should('contain', 'Category publish')
// })
//
// it('create category with status private', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/categories')
// cy.location('hash').should('eq', '#/categories')
// //cy.get('#button-category-creation').click()
// cy.get('.button').click()
// cy.location('hash').should('eq', '#/categories/new')
// cy.get('#tainacan-text-name').type('Category private')
// cy.get('#tainacan-text-description').type('description category private')
// cy.get('#tainacan-select-status').select('Private').should('have.value', 'private')
// cy.get('#button-submit-category-creation').click()
// cy.location('hash').should('eq', '#/categories/')
// cy.get('td').should('contain', 'Category private')
// })
//
// it('create category with status draft', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/categories')
// cy.location('hash').should('eq', '#/categories')
// //cy.get('#button-category-creation').click()
// cy.get('.button').click()
// cy.location('hash').should('eq', '#/categories/new')
// cy.get('#tainacan-text-name').type('Category draft')
// cy.get('#tainacan-text-description').type('description category draft')
// cy.get('#tainacan-select-status').select('Draft').should('have.value', 'draft')
// cy.get('#button-submit-category-creation').click()
// cy.location('hash').should('eq', '#/categories/')
// cy.get('td').should('not.contain', 'Category draft')
// })
//
// it('create category with status draft', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/categories')
// cy.location('hash').should('eq', '#/categories')
// //cy.get('#button-category-creation').click()
// cy.get('.button').click()
// cy.location('hash').should('eq', '#/categories/new')
// cy.get('#tainacan-text-name').type('Category trash')
// cy.get('#tainacan-text-description').type('description category trash')
// cy.get('#tainacan-select-status').select('Trash').should('have.value', 'trash')
// cy.get('#button-submit-category-creation').click()
// cy.location('hash').should('eq', '#/categories/')
// cy.get('td').should('not.contain', 'Category trash')
// })
//
// it('create category color', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/categories')
// cy.location('hash').should('eq', '#/categories')
// //cy.get('#button-category-creation').click()
// cy.get('.button').click()
// cy.location('hash').should('eq', '#/categories/new')
// cy.get('#tainacan-text-name').type('Category color')
// cy.get('#tainacan-text-description').type('description category color')
// cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
// cy.get('#button-submit-category-creation').click()
// cy.location('hash').should('eq', '#/categories/')
// cy.get('td').should('contain', 'Category color')
// })
//
// it('delete category color', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/categories')
// cy.location('hash').should('eq', '#/categories')
// cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
// cy.get('.b-table').should('contain', 'Category trash')
// cy.get(':nth-child(1) > [data-label="Actions"] > :nth-child(1) > #button-delete > .icon > .mdi').click()
// cy.get('.modal-card').should('have.class', 'animation-content')
// cy.get('.is-primary').click()
// cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
// cy.get('.b-table').should('not.contain', 'Category trash')
// })
})
})

View File

@ -1,4 +1,4 @@
describe('Tainacan Plugin Test', function () {
describe('Collection test', function () {
beforeEach(() => {
cy.loginByUI()
})
@ -7,80 +7,91 @@ describe('Tainacan Plugin Test', function () {
cy.clearDB()
})
context('Collections', function(){
context('CRUD collections', function(){
it('canceled collection', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book canceled')
cy.get('#tainacan-text-description').type('description book canceled')
cy.get('#button-cancel-collection-creation').click()
cy.url().should('contain', '/wp-admin/admin.php?page=tainacan_admin#/collections/')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections/')
cy.get('td').should('not.contain', 'Book canceled')
})
it('create collection with status publish', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book publish')
cy.get('#tainacan-text-description').type('description book publish')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book publish')
})
it('create collection with status private', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book private')
cy.get('#tainacan-text-description').type('description book private')
cy.get('#tainacan-select-status').select('Private').should('have.value', 'private')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book private')
})
it('create collection with status draft', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book draft')
cy.get('#tainacan-text-description').type('description book draft')
cy.get('#tainacan-select-status').select('Draft').should('have.value', 'draft')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Book draft')
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('not.contain', 'Book draft')
})
it('create collection with status trash', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book trash')
cy.get('#tainacan-text-description').type('description book trash')
cy.get('#tainacan-select-status').select('Trash').should('have.value', 'trash')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Book trash')
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('not.contain', 'Book trash')
})
it('delete collection', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book delete')
cy.get('#tainacan-text-description').type('description book delete')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book delete')
cy.get(':nth-child(1) > [data-label="Actions"] > :nth-child(1) > #button-delete > .icon > .mdi').click()
cy.get('.modal-card-body').should('contain', 'Do you really want to delete this collection?')
cy.get('.is-primary').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('not.contain', 'Book delete')
})
})
@ -88,111 +99,141 @@ describe('Tainacan Plugin Test', function () {
context('Create many collections for verify persistence the datas', function(){
it('create many collections', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 1')
cy.get('#tainacan-text-description').type('description book 1')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 1')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 2')
cy.get('#tainacan-text-description').type('description book 2')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 2')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 3')
cy.get('#tainacan-text-description').type('description book 3')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 3')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 4')
cy.get('#tainacan-text-description').type('description book 4')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 4')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 5')
cy.get('#tainacan-text-description').type('description book 5')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 5')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 6')
cy.get('#tainacan-text-description').type('description book 6')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 6')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 7')
cy.get('#tainacan-text-description').type('description book 7')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 7')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 8')
cy.get('#tainacan-text-description').type('description book 8')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 8')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 9')
cy.get('#tainacan-text-description').type('description book 9')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 9')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 10')
cy.get('#tainacan-text-description').type('description book 10')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 10')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 11')
cy.get('#tainacan-text-description').type('description book 11')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 11')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 12')
cy.get('#tainacan-text-description').type('description book 12')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 12')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 13')
cy.get('#tainacan-text-description').type('description book 13')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 13')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 14')
cy.get('#tainacan-text-description').type('description book 14')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 14')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book 15')
cy.get('#tainacan-text-description').type('description book 15')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book 15')
})
})
@ -200,11 +241,12 @@ describe('Tainacan Plugin Test', function () {
context('Check all collections', function(){
it('check if collections are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('.active-fields-area >').should('contain', 'Book publish')
cy.location('hash').should('eq', '#/collections')
cy.get('select').select('24').should('have.value', '24')
cy.get('.b-table').should('contain', 'Book publish')
.and('contain', 'Book private')
.and('contain', 'Book draft')
.and('contain', 'Book trash')
.and('not.contain', 'Book draft')
.and('not.contain', 'Book trash')
.and('contain', 'Book 1')
.and('contain', 'Book 2')
.and('contain', 'Book 3')

View File

@ -1,4 +1,4 @@
context('create category-type fields tests', function(){
context('Category field test', function(){
beforeEach(() => {
cy.loginByUI()
})
@ -9,8 +9,8 @@ context('create category-type fields tests', function(){
it('create collection for create fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.contains('New Collection').click()
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('#button-collection-creation').click()
cy.get('#tainacan-text-name').type('Book Fields')
cy.get('#tainacan-text-description').type('Descrição book Fields')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
@ -21,7 +21,7 @@ context('create category-type fields tests', function(){
it('create taxonomies for create relationship', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get(':nth-child(8) > a > .menu-text').click()
cy.get('.button').click()
cy.get('#tainacan-text-name').type('Cat 1')
@ -62,7 +62,7 @@ context('create category-type fields tests', function(){
it('canceled create category-type field public', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -78,7 +78,7 @@ context('create category-type fields tests', function(){
it('create category-type field public - input type = radio', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -96,7 +96,7 @@ context('create category-type fields tests', function(){
it('create category-type field public - input type = selectbox', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -114,7 +114,7 @@ context('create category-type fields tests', function(){
it('create category-type field private', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -132,7 +132,7 @@ context('create category-type fields tests', function(){
it('create category-type field public required', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -150,7 +150,7 @@ context('create category-type fields tests', function(){
it('create category-type field public multiple values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -168,7 +168,7 @@ context('create category-type fields tests', function(){
it('create category-type field public unique values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -186,7 +186,7 @@ context('create category-type fields tests', function(){
it('check if fields are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(7) > a').click()

View File

@ -9,7 +9,7 @@ describe('Date field test', function() {
it('create collection for create fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('#button-collection-creation').click()
cy.get('#tainacan-text-name').type('Date Fields')
cy.get('#tainacan-text-description').type('Description Date Fields')
@ -22,7 +22,7 @@ describe('Date field test', function() {
context('CRUD date field', function(){
it('create submission date field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -37,7 +37,7 @@ describe('Date field test', function() {
it('check create submission date field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -47,7 +47,7 @@ describe('Date field test', function() {
it('create year of manufacture field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -62,7 +62,7 @@ describe('Date field test', function() {
it('check create year of manufacture field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -72,7 +72,7 @@ describe('Date field test', function() {
it('edit year of manufacture field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -87,7 +87,7 @@ describe('Date field test', function() {
it('create year field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -102,7 +102,7 @@ describe('Date field test', function() {
it('delete year field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -114,7 +114,7 @@ describe('Date field test', function() {
it('check not contain year field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -126,7 +126,7 @@ describe('Date field test', function() {
context('Diseble date field', function(){
it('create purchase day field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -141,7 +141,7 @@ describe('Date field test', function() {
it('disebled purchase day field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -152,7 +152,7 @@ describe('Date field test', function() {
it('check disebled purchase day field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -164,7 +164,7 @@ describe('Date field test', function() {
context('Check required fields', function(){
it('create blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -184,7 +184,7 @@ describe('Date field test', function() {
it('check not contain blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -196,7 +196,7 @@ describe('Date field test', function() {
context('Create date field private', function(){
it('create date private field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -211,7 +211,7 @@ describe('Date field test', function() {
it('check create date private field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -225,7 +225,7 @@ describe('Date field test', function() {
context('"Not saved" label vs. "cancel button"', function(){
it('create warranty field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -240,7 +240,7 @@ describe('Date field test', function() {
it('check that Not Saved label wasnt inserted, and changes were lost', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -257,7 +257,7 @@ describe('Date field test', function() {
it('check if the message “Not Saved” appeared next to the field name', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -283,7 +283,7 @@ describe('Date field test', function() {
context('create date-types fields tests', function(){
it('canceled create date field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -298,7 +298,7 @@ describe('Date field test', function() {
it('create date-type field public required', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -314,7 +314,7 @@ describe('Date field test', function() {
it('create date-type field public multiple values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -330,7 +330,7 @@ describe('Date field test', function() {
it('create date-type field public unique values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -348,7 +348,7 @@ describe('Date field test', function() {
context('Leave page without saving field editions', function(){
it('Leave page without saving field editions', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -370,7 +370,7 @@ describe('Date field test', function() {
context('Field loading for paging and persistence testing', function(){
it('create dates fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -429,7 +429,7 @@ describe('Date field test', function() {
it('check if fields are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()

View File

@ -9,8 +9,7 @@ describe('Numeric field test', function() {
it('create collection for create fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.contains('New Collection').click()
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('#button-collection-creation').click()
cy.get('#tainacan-text-name').type('Numeric Fields')
cy.get('#tainacan-text-description').type('Description Numeric Fields')
@ -23,7 +22,7 @@ describe('Numeric field test', function() {
context('CRUD numeric field', function(){
it('create counter field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -38,7 +37,7 @@ describe('Numeric field test', function() {
it('check create counter field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -48,7 +47,7 @@ describe('Numeric field test', function() {
it('create code field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -63,7 +62,7 @@ describe('Numeric field test', function() {
it('check create code field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -73,7 +72,7 @@ describe('Numeric field test', function() {
it('edit code field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -88,7 +87,7 @@ describe('Numeric field test', function() {
it('create number field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -103,7 +102,7 @@ describe('Numeric field test', function() {
it('delete number field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -115,7 +114,7 @@ describe('Numeric field test', function() {
it('check not contain year field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -127,7 +126,7 @@ describe('Numeric field test', function() {
context('Diseble numeric field', function(){
it('create registration number field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -142,7 +141,7 @@ describe('Numeric field test', function() {
it('disebled registration number field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -153,7 +152,7 @@ describe('Numeric field test', function() {
it('check disebled registration number field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -165,7 +164,7 @@ describe('Numeric field test', function() {
context('Check required fields', function(){
it('create blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -185,7 +184,7 @@ describe('Numeric field test', function() {
it('check not contain blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -197,7 +196,7 @@ describe('Numeric field test', function() {
context('Create numeric field private', function(){
it('create date private field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -205,29 +204,28 @@ describe('Numeric field test', function() {
cy.get('.field > :nth-child(2) > :nth-child(4)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric private')
cy.get('.textarea').type('description private')
cy.get('#tainacan-select-status-publish > .check').click()
//cy.get('#tainacan-select-status-private > .check').click()
cy.get('#tainacan-select-status-private > .check').click()
cy.get(':nth-child(2) > .button').click()
//cy.get('.active-fields-area >').should('contain', 'Numeric private')
cy.get('.active-fields-area >').should('contain', 'Numeric private')
})
// it('check create numeric private field', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.get('h1').should('contain', 'Collections Page')
// cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
// cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
// cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
// cy.get('h1').should('contain', 'Collection Fields Edition Page')
// cy.get('.active-fields-area > :nth-child(6) > .handle > .field-name').should('contain', 'Numeric private')
// cy.get(':nth-child(6) > .handle > .controls > :nth-child(2) > .icon > .mdi').click()
// cy.get('#tainacan-select-status-private > .check').should('be.selected')
// })
it('check create numeric private field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.active-fields-area > :nth-child(6) > .handle > .field-name').should('contain', 'Numeric private')
cy.get(':nth-child(6) > .handle > .controls > :nth-child(2) > .icon > .mdi').click()
cy.get('#tainacan-select-status-private > .check').should('be.selected')
})
})
context('"Not saved" label vs. "cancel button"', function(){
it('create amount field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -242,7 +240,7 @@ describe('Numeric field test', function() {
it('check that Not Saved label wasnt inserted, and changes were lost', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -259,7 +257,7 @@ describe('Numeric field test', function() {
it('check if the message “Not Saved” appeared next to the field name', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -285,7 +283,7 @@ describe('Numeric field test', function() {
context('create date-types fields tests', function(){
it('canceled create numeric field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -300,7 +298,7 @@ describe('Numeric field test', function() {
it('create numeric-type field public required', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -316,7 +314,7 @@ describe('Numeric field test', function() {
it('create numeric-type field public multiple values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -332,7 +330,7 @@ describe('Numeric field test', function() {
it('create numeric-type field public unique values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -350,7 +348,7 @@ describe('Numeric field test', function() {
context('Leave page without saving field editions', function(){
it('Leave page without saving field editions', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -372,7 +370,7 @@ describe('Numeric field test', function() {
context('Field loading for paging and persistence testing', function(){
it('create numerics fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -431,7 +429,7 @@ describe('Numeric field test', function() {
it('check if fields are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()

View File

@ -1,4 +1,4 @@
context('create relationship-type fields tests', function(){
context('Relationship field test', function(){
beforeEach(() => {
cy.loginByUI()
})
@ -9,8 +9,8 @@ context('create relationship-type fields tests', function(){
it('create collection for create fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.contains('New Collection').click()
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('#button-collection-creation').click()
cy.get('#tainacan-text-name').type('Book Fields')
cy.get('#tainacan-text-description').type('Descrição book Fields')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
@ -21,7 +21,7 @@ context('create relationship-type fields tests', function(){
it('create collection for create relationship', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.contains('New Collection').click()
cy.get('#tainacan-text-name').type('Book relationship')
cy.get('#tainacan-text-description').type('Descrição book relationship')
@ -33,7 +33,7 @@ context('create relationship-type fields tests', function(){
it('canceled create relationship-type field public', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -49,7 +49,7 @@ context('create relationship-type fields tests', function(){
it('create relationship-type field public', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -68,7 +68,7 @@ context('create relationship-type fields tests', function(){
it('create relationship-type field private', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -87,7 +87,7 @@ context('create relationship-type fields tests', function(){
it('create relationship-type field public required', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -107,7 +107,7 @@ context('create relationship-type fields tests', function(){
it('create relationship-type field public multiple values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -127,7 +127,7 @@ context('create relationship-type fields tests', function(){
it('create relationship-type field public unique values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -147,7 +147,7 @@ context('create relationship-type fields tests', function(){
it('check if fields are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()

View File

@ -0,0 +1,486 @@
describe('Selectbox field test', function() {
beforeEach(() => {
cy.loginByUI()
})
it('clear DB', function(){
cy.clearDB()
})
it('create collection for create fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('#button-collection-creation').click()
cy.get('#tainacan-text-name').type('Selectbox Fields')
cy.get('#tainacan-text-description').type('Description Selectbox Fields')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('#primary-menu > .menu > .menu-header > .menu-list > li > .router-link-active > .icon > .mdi').click()
cy.get('.b-table').should('contain', 'Selectbox Fields')
})
context('CRUD selectbox field', function(){
it('create reviewed field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Reviewed')
cy.get('.textarea').type('description reviewed')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('op1{enter}op2{enter}op3')
cy.get(':nth-child(2) > .button').click()
cy.get('.handle > .field-name').should('contain', 'Reviewed')
})
it('check create reviewed field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.contains('Reviewed')
})
it('create edited field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Edited')
cy.get('.textarea').type('description edited')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('op1{enter}op2{enter}op3')
cy.get(':nth-child(2) > .button').click()
cy.get('.handle > .field-name').should('contain', 'Edited')
})
it('check create edited field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.contains('Edited')
})
it('edit edited field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get(':nth-child(4) > .handle > .controls > :nth-child(2) > .icon > .mdi').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('Edited edited')
cy.get('.textarea').type(' edited')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('op1{enter}op2{enter}op3')
cy.get(':nth-child(2) > .button').click()
cy.get('.handle > .field-name').should('contain', 'Edited edited')
})
it('create itsCool field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}itsCool')
cy.get('.textarea').type('description itsCool')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('op1{enter}op2{enter}op3')
cy.get(':nth-child(2) > .button').click()
cy.get('.handle > .field-name').should('contain', 'itsCool')
})
it('delete itsCool field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.contains('itsCool')
cy.get(':nth-child(5) > .handle > .controls > :nth-child(3) > .icon > .mdi').click()
cy.get('.handle > .field-name').should('not.eq', 'itsCool')
})
it('check not contain itsCool field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.handle > .field-name').should('not.eq', 'itsCool')
})
})
context('Diseble selectbox field', function(){
it('create verified field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Verified disebled')
cy.get('.textarea').type('description verified')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('YES{enter}NO')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'Verified disebled')
})
it('disebled verified field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get(':nth-child(5) > .handle > .controls > .switch > .check').click()
cy.get('.active-fields-area > :nth-child(5)').should('have.class', 'disabled-field')
})
it('check disebled verified field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.active-fields-area > :nth-child(5)').should('have.class', 'disabled-field')
})
})
context('Check required fields', function(){
it('create blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('.not-focusable-item > .handle > .label-details').should('contain', 'Not saved')
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Bank{selectall}{del}')
cy.get('.textarea').clear()
cy.get('#tainacan-select-status-publish > .check').click()
cy.get(':nth-child(2) > .button').click()
cy.get('.not-focusable-item > .handle > .field-name').should('have.class', 'is-danger')
//cy.get('#fieldEditForm > :nth-child(1) > .control > .input').should('have.class', 'is-danger')
cy.get('.help').should('have.class', 'is-danger')
cy.get(':nth-child(1) > .button').click()
cy.get('.active-fields-area > :nth-child(6) > .handle > .field-name').should('not.contain', 'Blank').and('contain', 'Selectbox')
cy.get('.active-fields-area > :nth-child(6) > .handle > .label-details').should('contain', 'Not saved')
})
it('check not contain blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.active-fields-area').should('not.contain', 'Blank')
})
})
context('Create selectbox field private', function(){
it('create selectbox private field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox private')
cy.get('.textarea').type('description private')
cy.get('#tainacan-select-status-publish > .check').click()
//cy.get('#tainacan-select-status-private > .check').click()
cy.get('.autocomplete > .control > .input').type('yes{enter}no')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'Selectbox private')
})
// it('check create selectbox private field', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
// cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
// cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
// cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
// cy.get('h1').should('contain', 'Collection Fields Edition Page')
// cy.get('.active-fields-area > :nth-child(6) > .handle > .field-name').should('contain', 'Selectbox private')
// cy.get(':nth-child(6) > .handle > .controls > :nth-child(2) > .icon > .mdi').click()
// cy.get('#tainacan-select-status-private > .check').should('be.selected')
// })
})
context('"Not saved" label vs. "cancel button"', function(){
it('create likes field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Likes')
cy.get('.textarea').type('description likes')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('yes{enter}no')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'Likes')
})
it('check that Not Saved label wasnt inserted, and changes were lost', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.active-fields-area > :nth-child(7) > .handle > .field-name').should('contain', 'Likes')
cy.get(':nth-child(7) > .handle > .controls > :nth-child(2) > .icon > .mdi').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type(' edited')
cy.get('.textarea').type(' edited')
cy.get('#tainacan-select-status-private > .check').click()
cy.get('.autocomplete > .control > .input').type('dont')
cy.get(':nth-child(1) > .button').click()
cy.get('.active-fields-area >').should('not.contain', 'Likes edited')
cy.get('.active-fields-area > :nth-child(7) > .handle > .label-details').should('not.contain', 'Not saved')
})
it('check if the message “Not Saved” appeared next to the field name', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox Type')
cy.get('.textarea').type('description new')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('yes{enter}no')
cy.get(':nth-child(1) > .button').click()
cy.get('.active-fields-area > :nth-child(8) > .handle > .field-name').should('not.eq', 'Selectbox Type').and('contain', 'Selectbox')
cy.get('.active-fields-area > :nth-child(8) > .handle > .label-details').should('contain', 'Not saved')
cy.get(':nth-child(8) > .handle > .controls > :nth-child(2) > .icon > .mdi').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox Type')
cy.get('.autocomplete > .control > .input').type('yes{enter}no')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area > :nth-child(8) > .handle > .field-name').should('contain', 'Selectbox Type').and('not.eq', 'Selectbox')
cy.get('.active-fields-area > :nth-child(8) > .handle > .label-details').should('not.eq', 'Not saved')
})
})
context('Fields Sorting', function(){
})
context('create selectbox-types fields tests', function(){
it('canceled create selectbox field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox name canceled')
cy.get('.textarea').type('description')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('Y{enter}n')
cy.get(':nth-child(1) > .button').click()
cy.get('.active-fields-area >').should('not.contain', 'Selectbox name canceled')
})
it('create selectbox-type field public required', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox name public required')
cy.get('.textarea').type('book description required')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get(':nth-child(2) > .b-checkbox > .check').click()
cy.get('.autocomplete > .control > .input').type('Y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'Selectbox name public required')
})
it('create selectbox-type field public multiple values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox name public multiple values')
cy.get('.textarea').type('book description multiple values')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get(':nth-child(3) > .b-checkbox > .check').click()
cy.get('.autocomplete > .control > .input').type('Y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'Selectbox name public multiple values')
})
it('create selectbox-type field public unique values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox name public unique values')
cy.get('.textarea').type('name book description multiple values')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get(':nth-child(4) > .b-checkbox > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'Selectbox name public unique values')
})
})
context('Leave page without saving field editions', function(){
it('Leave page without saving field editions', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Not Saved')
cy.get('.textarea').type('description')
cy.get('#tainacan-select-status-publish > .check').click()
cy.contains('Items').click()
cy.get('.modal-card').should('have.class', 'animation-content')
cy.get('.modal-card-foot > :nth-child(1)').click()
cy.get(':nth-child(1) > .button').click()
cy.get('.active-fields-area >').should('not.contain', 'Not Saved').and('contain', 'Selectbox')
cy.get('.menu > :nth-child(2) > :nth-child(8) > a').click()
cy.get('.modal-card').should('have.class', 'is-titleless')
})
})
context('Field loading for paging and persistence testing', function(){
it('create selectbox fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)clearDB').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox 1')
cy.get('.textarea').type('description selectbox')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox 2')
cy.get('.textarea').type('description selectbox')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox 3')
cy.get('.textarea').type('description selectbox')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox 4')
cy.get('.textarea').type('description selectbox')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox 5')
cy.get('.textarea').type('description selectbox')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox 6')
cy.get('.textarea').type('description selectbox')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox 7')
cy.get('.textarea').type('description selectbox')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox 8')
cy.get('.textarea').type('description selectbox')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox 9')
cy.get('.textarea').type('description selectbox')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox 10')
cy.get('.textarea').type('description selectbox')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('y{enter}n')
cy.get(':nth-child(2) > .button').click()
})
it('check if fields are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.active-fields-area >').should('contain', 'Reviewed')
.and('contain', 'Edited edited')
.and('contain', 'Verified disabled')
.and('contain', 'Selectbox Private')
.and('not.contain', 'Blank')
.and('contain', 'Likes')
.and('contain', 'Selectbox Type')
.and('not.contain', 'Selectbox name canceled')
.and('contain', 'Selectbox name public required')
.and('contain', 'Selectbox name public multiple values')
.and('contain', 'Selectbox name public unique values')
.and('contain', 'Selectbox 1')
.and('contain', 'Selectbox 2')
.and('contain', 'Selectbox 3')
.and('contain', 'Selectbox 4')
.and('contain', 'Selectbox 5')
.and('contain', 'Selectbox 6')
.and('contain', 'Selectbox 7')
.and('contain', 'Selectbox 8')
.and('contain', 'Selectbox 9')
.and('contain', 'Selectbox 10')
})
})
})

View File

@ -9,7 +9,7 @@ describe('TextArea field test', function() {
it('create collection for create fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('#button-collection-creation').click()
cy.get('#tainacan-text-name').type('TextArea Fields')
cy.get('#tainacan-text-description').type('Description TextArea Fields')
@ -22,7 +22,7 @@ describe('TextArea field test', function() {
context('CRUD textArea field', function(){
it('create model field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -37,7 +37,7 @@ describe('TextArea field test', function() {
it('check create model field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -47,7 +47,7 @@ describe('TextArea field test', function() {
it('create color field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -62,7 +62,7 @@ describe('TextArea field test', function() {
it('check create color field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -72,7 +72,7 @@ describe('TextArea field test', function() {
it('edit color field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -87,7 +87,7 @@ describe('TextArea field test', function() {
it('create door field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -102,7 +102,7 @@ describe('TextArea field test', function() {
it('delete door field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -114,7 +114,7 @@ describe('TextArea field test', function() {
it('check not contain door field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -126,7 +126,7 @@ describe('TextArea field test', function() {
context('Diseble textArea field', function(){
it('create motor field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -141,7 +141,7 @@ describe('TextArea field test', function() {
it('disebled motor field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -152,7 +152,7 @@ describe('TextArea field test', function() {
it('check disebled motor field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -164,7 +164,7 @@ describe('TextArea field test', function() {
context('Check required fields', function(){
it('create blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -184,7 +184,7 @@ describe('TextArea field test', function() {
it('check not contain blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -196,7 +196,7 @@ describe('TextArea field test', function() {
context('Create textArea field private', function(){
it('create private field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -211,7 +211,7 @@ describe('TextArea field test', function() {
it('check create private field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -225,7 +225,7 @@ describe('TextArea field test', function() {
context('"Not saved" label vs. "cancel button"', function(){
it('create brand field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -240,7 +240,7 @@ describe('TextArea field test', function() {
it('check that Not Saved label wasnt inserted, and changes were lost', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -257,7 +257,7 @@ describe('TextArea field test', function() {
it('check if the message “Not Saved” appeared next to the field name', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -283,7 +283,7 @@ describe('TextArea field test', function() {
context('create textArea-types fields tests', function(){
it('canceled create textArea field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -298,7 +298,7 @@ describe('TextArea field test', function() {
it('create textArea-type field public required', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -314,7 +314,7 @@ describe('TextArea field test', function() {
it('create textArea-type field public multiple values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -330,7 +330,7 @@ describe('TextArea field test', function() {
it('create textArea-type field public unique values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -348,7 +348,7 @@ describe('TextArea field test', function() {
context('Leave page without saving field editions', function(){
it('Leave page without saving field editions', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -370,7 +370,7 @@ describe('TextArea field test', function() {
context('Field loading for paging and persistence testing', function(){
it('create textAreas fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -438,7 +438,7 @@ describe('TextArea field test', function() {
it('check if fields are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()

View File

@ -9,7 +9,7 @@ describe('Text field test', function() {
it('create collection for create fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('#button-collection-creation').click()
cy.get('#tainacan-text-name').type('Book Text Fields')
cy.get('#tainacan-text-description').type('Description book Fields')
@ -22,7 +22,7 @@ describe('Text field test', function() {
context('CRUD text field', function(){
it('create actor field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -37,7 +37,7 @@ describe('Text field test', function() {
it('check create actor field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -47,7 +47,7 @@ describe('Text field test', function() {
it('create location field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -62,7 +62,7 @@ describe('Text field test', function() {
it('check create location field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -72,7 +72,7 @@ describe('Text field test', function() {
it('edit location field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -87,7 +87,7 @@ describe('Text field test', function() {
it('create denomination field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -102,7 +102,7 @@ describe('Text field test', function() {
it('delete denomination field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -114,7 +114,7 @@ describe('Text field test', function() {
it('check not contain denomination field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -126,7 +126,7 @@ describe('Text field test', function() {
context('Diseble text field', function(){
it('create record field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -141,7 +141,7 @@ describe('Text field test', function() {
it('disebled record field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -152,7 +152,7 @@ describe('Text field test', function() {
it('check disebled record field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -164,7 +164,7 @@ describe('Text field test', function() {
context('Check required fields', function(){
it('create blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -184,7 +184,7 @@ describe('Text field test', function() {
it('check not contain blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -196,13 +196,13 @@ describe('Text field test', function() {
context('Create text field private', function(){
it('create private field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(1)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Text Text Private')
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Text Private')
cy.get('.textarea').type('description private')
cy.get('#tainacan-select-status-private > .check').click()
cy.get(':nth-child(2) > .button').click()
@ -211,7 +211,7 @@ describe('Text field test', function() {
it('check create private field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -225,7 +225,7 @@ describe('Text field test', function() {
context('"Not saved" label vs. "cancel button"', function(){
it('create denomination field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -240,7 +240,7 @@ describe('Text field test', function() {
it('check that Not Saved label wasnt inserted, and changes were lost', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -257,7 +257,7 @@ describe('Text field test', function() {
it('check if the message “Not Saved” appeared next to the field name', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -283,7 +283,7 @@ describe('Text field test', function() {
context('create text-type fields tests', function(){
it('canceled create text field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -298,7 +298,7 @@ describe('Text field test', function() {
it('create text-type field public required', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -314,7 +314,7 @@ describe('Text field test', function() {
it('create text-type field public multiple values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -330,7 +330,7 @@ describe('Text field test', function() {
it('create text-type field public unique values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -348,7 +348,7 @@ describe('Text field test', function() {
context('Leave page without saving field editions', function(){
it('Leave page without saving field editions', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -370,7 +370,7 @@ describe('Text field test', function() {
context('Field loading for paging and persistence testing', function(){
it('create texts fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
@ -438,7 +438,7 @@ describe('Text field test', function() {
it('check if fields are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location().should((loc) => {expect(loc.hash).to.eq('#/collections')})
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()

View File

@ -1,4 +1,4 @@
describe('Tainacan Plugin Test', function () {
describe('Item tests', function () {
beforeEach(() => {
cy.loginByUI()
})
@ -7,27 +7,45 @@ describe('Tainacan Plugin Test', function () {
cy.clearDB()
})
it('create collection for crud items', function(){
Cypress.Commands.add('createCollection', (name) => {
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
//cy.get('#button-collection-creation').click()
cy.contains('New Collection').click()
cy.get('#tainacan-text-name').type('Book Items')
cy.get('#tainacan-text-description').type('description book items')
cy.location('hash').should('eq', '#/collections')
cy.get('#button-collection-creation').click()
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type(name)
cy.get('#tainacan-text-description').type('description'+name)
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Book Items')
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', name)
})
context('Items', function(){
it('create collection', function(){
cy.createCollection('Book itens')
})
// it('create collection for crud items', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.location('hash').should('eq', '#/collections')
// cy.get('#button-collection-creation').click()
// cy.location('hash').should('eq', '#/collections/new')
// cy.get('#tainacan-text-name').type('Book Items')
// cy.get('#tainacan-text-description').type('description book items')
// cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
// cy.get('#button-submit-collection-creation').click()
// cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
// cy.location('hash').should('eq', '#/collections')
// cy.get('.b-table').should('contain', 'Book Items')
// })
context('CRUD items', function(){
it('canceled create item', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item canceled')
cy.get('#tainacan-textarea-description').type('Item canceled description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
@ -38,11 +56,10 @@ describe('Tainacan Plugin Test', function () {
it('create item with status publish', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item publish')
cy.get('#tainacan-textarea-description').type('Item publish description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
@ -53,11 +70,10 @@ describe('Tainacan Plugin Test', function () {
it('create item with status private', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item private')
cy.get('#tainacan-textarea-description').type('Item private description')
cy.get('#status-select').select('Private').should('have.value', 'private')
@ -68,41 +84,38 @@ describe('Tainacan Plugin Test', function () {
it('create item with status draft', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item draft')
cy.get('#tainacan-textarea-description').type('Item draft description')
cy.get('#status-select').select('Draft').should('have.value', 'draft')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item draft')
cy.get('.b-table').should('not.contain', 'Item draft')
})
it('create item with status trash', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item trash')
cy.get('#tainacan-textarea-description').type('Item trash description')
cy.get('#status-select').select('Trash').should('have.value', 'trash')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item trash')
cy.get('.b-table').should('not.contain', 'Item trash')
})
it('delete item', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item delete')
cy.get('#tainacan-textarea-description').type('Item delete description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
@ -120,123 +133,108 @@ describe('Tainacan Plugin Test', function () {
context('Create many collections for verify persistence the datas', function(){
it('create many items', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 1')
cy.get('#tainacan-textarea-description').type('Item 1 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 1')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 2')
cy.get('#tainacan-textarea-description').type('Item 2 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 2')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 3')
cy.get('#tainacan-textarea-description').type('Item 3 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 3')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 4')
cy.get('#tainacan-textarea-description').type('Item 4 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 4')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 5')
cy.get('#tainacan-textarea-description').type('Item 5 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 5')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 6')
cy.get('#tainacan-textarea-description').type('Item 6 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 6')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 7')
cy.get('#tainacan-textarea-description').type('Item 7 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 7')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 8')
cy.get('#tainacan-textarea-description').type('Item 8 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 8')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 9')
cy.get('#tainacan-textarea-description').type('Item 9 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 9')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 10')
cy.get('#tainacan-textarea-description').type('Item 10 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 10')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 11')
cy.get('#tainacan-textarea-description').type('Item 11 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 11')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 12')
cy.get('#tainacan-textarea-description').type('Item 12 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 12')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 13')
cy.get('#tainacan-textarea-description').type('Item 13 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 13')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 14')
cy.get('#tainacan-textarea-description').type('Item 14 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 14')
//cy.get('#button-item-creation').click()
cy.get('.sub-header > :nth-child(1) > .button').click()
cy.get('#button-item-creation').click()
cy.get('#tainacan-text-title').type('Item 15')
cy.get('#tainacan-textarea-description').type('Item 15 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
@ -249,13 +247,14 @@ describe('Tainacan Plugin Test', function () {
context('Check all items', function(){
it('check if collections are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.location('hash').should('eq', '#/collections')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.active-fields-area >').should('contain', 'Item publish')
cy.get('.field-body > .field > .control > .select > select').select('24').should('have.value', '24')
cy.get('.table').should('contain', 'Item publish')
.and('contain', 'Item private')
.and('contain', 'Item draft')
.and('contain', 'Item trash')
.and('not.contain', 'Item draft')
.and('not.contain', 'Item trash')
.and('contain', 'Item 1')
.and('contain', 'Item 2')
.and('contain', 'Item 3')

View File

@ -1,471 +0,0 @@
describe('Selectbox field test', function() {
beforeEach(() => {
cy.loginByUI()
})
it('clear DB', function(){
cy.clearDB()
})
it('create collection for create fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.contains('New Collection').click()
//cy.get('#button-collection-creation').click()
cy.get('#tainacan-text-name').type('Selectbox Fields')
cy.get('#tainacan-text-description').type('Description Selectbox Fields')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('#primary-menu > .menu > .menu-header > .menu-list > li > .router-link-active > .icon > .mdi').click()
cy.get('.b-table').should('contain', 'Selectbox Fields')
})
context('CRUD selectbox field', function(){
it('create reviewed field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Reviewed')
cy.get('.textarea').type('description reviewed')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('op1{enter}op2{enter}op3')
cy.get(':nth-child(2) > .button').click()
cy.get('.handle > .field-name').should('contain', 'Reviewed')
})
it('check create reviewed field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.contains('Reviewed')
})
it('create edited field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Edited')
cy.get('.textarea').type('description edited')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('op1{enter}op2{enter}op3')
cy.get(':nth-child(2) > .button').click()
cy.get('.handle > .field-name').should('contain', 'Edited')
})
it('check create edited field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.contains('Edited')
})
it('edit edited field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get(':nth-child(4) > .handle > .controls > :nth-child(2) > .icon > .mdi').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('Edited edited')
cy.get('.textarea').type(' edited')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('op1{enter}op2{enter}op3')
cy.get(':nth-child(2) > .button').click()
cy.get('.handle > .field-name').should('contain', 'Edited edited')
})
it('create itsCool field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}itsCool')
cy.get('.textarea').type('description itsCool')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('op1{enter}op2{enter}op3')
cy.get(':nth-child(2) > .button').click()
cy.get('.handle > .field-name').should('contain', 'itsCool')
})
it('delete itsCool field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.contains('itsCool')
cy.get(':nth-child(5) > .handle > .controls > :nth-child(3) > .icon > .mdi').click()
cy.get('.handle > .field-name').should('not.eq', 'itsCool')
})
it('check not contain itsCool field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.handle > .field-name').should('not.eq', 'itsCool')
})
})
context('Diseble selectbox field', function(){
it('create verified field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Verified disebled')
cy.get('.textarea').type('description verified')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('YES{enter}NO')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'Verified disebled')
})
it('disebled verified field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get(':nth-child(5) > .handle > .controls > .switch > .check').click()
cy.get('.active-fields-area > :nth-child(5)').should('have.class', 'disabled-field')
})
it('check disebled verified field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.active-fields-area > :nth-child(5)').should('have.class', 'disabled-field')
})
})
context('Check required fields', function(){
it('create blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('.not-focusable-item > .handle > .label-details').should('contain', 'Not saved')
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Bank{selectall}{del}')
cy.get('.textarea').clear()
cy.get('#tainacan-select-status-publish > .check').click()
cy.get(':nth-child(2) > .button').click()
cy.get('.not-focusable-item > .handle > .field-name').should('have.class', 'is-danger')
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').should('have.class', 'is-danger')
cy.get(':nth-child(1) > .button').click()
cy.get('.active-fields-area > :nth-child(6) > .handle > .field-name').should('not.contain', 'Blank').and('contain', 'Selectbox')
cy.get('.active-fields-area > :nth-child(6) > .handle > .label-details').should('contain', 'Not saved')
})
it('check not contain blank field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.active-fields-area').should('not.contain', 'Blank')
})
})
context('Create selectbox field private', function(){
it('create selectbox private field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox private')
cy.get('.textarea').type('description private')
//cy.get('#tainacan-select-status-publish > .check').click()
cy.get('#tainacan-select-status-private > .check').click()
cy.get('.autocomplete > .control > .input').type('yes{enter}no')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'Selectbox private')
})
// it('check create selectbox private field', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.get('h1').should('contain', 'Collections Page')
// cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
// cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
// cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
// cy.get('h1').should('contain', 'Collection Fields Edition Page')
// cy.get('.active-fields-area > :nth-child(6) > .handle > .field-name').should('contain', 'Selectbox private')
// cy.get(':nth-child(6) > .handle > .controls > :nth-child(2) > .icon > .mdi').click()
// cy.get('#tainacan-select-status-private > .check').should('be.selected')
// })
})
context('"Not saved" label vs. "cancel button"', function(){
it('create likes field', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Likes')
cy.get('.textarea').type('description likes')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('yes{enter}no')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'Likes')
})
it('check that Not Saved label wasnt inserted, and changes were lost', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.active-fields-area > :nth-child(7) > .handle > .field-name').should('contain', 'Likes')
cy.get(':nth-child(7) > .handle > .controls > :nth-child(2) > .icon > .mdi').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type(' edited')
cy.get('.textarea').type(' edited')
cy.get('#tainacan-select-status-private > .check').click()
cy.get('.autocomplete > .control > .input').type('yes{enter}no')
cy.get(':nth-child(1) > .button').click()
cy.get('.active-fields-area >').should('not.contain', 'Likes edited')
cy.get('.active-fields-area > :nth-child(7) > .handle > .label-details').should('not.contain', 'Not saved')
})
it('check if the message “Not Saved” appeared next to the field name', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.get('h1').should('contain', 'Collections Page')
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(5)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox Type')
cy.get('.textarea').type('description new')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('.autocomplete > .control > .input').type('yes{enter}no')
cy.get(':nth-child(1) > .button').click()
cy.get('.active-fields-area > :nth-child(8) > .handle > .field-name').should('not.eq', 'Selectbox Type').and('contain', 'Selectbox')
cy.get('.active-fields-area > :nth-child(8) > .handle > .label-details').should('contain', 'Not saved')
cy.get(':nth-child(8) > .handle > .controls > :nth-child(2) > .icon > .mdi').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Selectbox Type')
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area > :nth-child(8) > .handle > .field-name').should('contain', 'Selectbox Type').and('not.eq', 'Selectbox')
cy.get('.active-fields-area > :nth-child(8) > .handle > .label-details').should('not.eq', 'Not saved')
})
})
// context('Fields Sorting', function(){
// })
//
// context('create date-types fields tests', function(){
// it('canceled create numeric field', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.get('h1').should('contain', 'Collections Page')
// cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
// cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
// cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
// cy.get('h1').should('contain', 'Collection Fields Edition Page')
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric name canceled')
// cy.get('.textarea').type('description')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(1) > .button').click()
// cy.get('.active-fields-area >').should('not.contain', 'Numeric name canceled')
// })
//
// it('create numeric-type field public required', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.get('h1').should('contain', 'Collections Page')
// cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
// cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
// cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
// cy.get('h1').should('contain', 'Collection Fields Edition Page')
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric name public required')
// cy.get('.textarea').type('book description required')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .b-checkbox > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.active-fields-area >').should('contain', 'Numeric name public required')
// })
//
// it('create numeric-type field public multiple values', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.get('h1').should('contain', 'Collections Page')
// cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
// cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
// cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
// cy.get('h1').should('contain', 'Collection Fields Edition Page')
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric name public multiple values')
// cy.get('.textarea').type('book description multiple values')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(3) > .b-checkbox > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.active-fields-area >').should('contain', 'Numeric name public multiple values')
// })
//
// it('create numeric-type field public unique values', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.get('h1').should('contain', 'Collections Page')
// cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
// cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
// cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
// cy.get('h1').should('contain', 'Collection Fields Edition Page')
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric name public unique values')
// cy.get('.textarea').type('name book description multiple values')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(4) > .b-checkbox > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.active-fields-area >').should('contain', 'Numeric name public unique values')
// })
// })
//
// context('Leave page without saving field editions', function(){
// it('Leave page without saving field editions', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.get('h1').should('contain', 'Collections Page')
// cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
// cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
// cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
// cy.get('h1').should('contain', 'Collection Fields Edition Page')
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Not Saved')
// cy.get('.textarea').type('description')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.contains('Items').click()
// cy.get('.modal-card').should('have.class', 'animation-content')
// cy.get('.modal-card-foot > :nth-child(1)').click()
// cy.get(':nth-child(1) > .button').click()
// cy.get('.active-fields-area >').should('not.contain', 'Not Saved').and('contain', 'Numeric')
// cy.get('.menu > :nth-child(2) > :nth-child(8) > a').click()
// cy.get('.modal-card').should('have.class', 'is-titleless')
// })
// })
//
// context('Field loading for paging and persistence testing', function(){
// it('create numerics fields', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.get('h1').should('contain', 'Collections Page')
// cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
// cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
// cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
// cy.get('h1').should('contain', 'Collection Fields Edition Page')
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric 1')
// cy.get('.textarea').type('description numeric')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric 2')
// cy.get('.textarea').type('description numeric')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric 3')
// cy.get('.textarea').type('description numeric')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric 4')
// cy.get('.textarea').type('description numeric')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric 5')
// cy.get('.textarea').type('description numeric')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric 6')
// cy.get('.textarea').type('description numeric')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric 7')
// cy.get('.textarea').type('description numeric')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric 8')
// cy.get('.textarea').type('description numeric')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric 9')
// cy.get('.textarea').type('description numeric')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .button').click()
// cy.get('.field > :nth-child(2) > :nth-child(4)').click()
// cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('{selectall}{del}Numeric 10')
// cy.get('.textarea').type('description numeric')
// cy.get('#tainacan-select-status-publish > .check').click()
// cy.get(':nth-child(2) > .button').click()
// })
//
// it('check if fields are updated to page', function(){
// cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
// cy.get('h1').should('contain', 'Collections Page')
// cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
// cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
// cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
// cy.get('h1').should('contain', 'Collection Fields Edition Page')
// cy.get('.active-fields-area >').should('contain', 'Reviewed')
// .and('contain', 'Edited edited')
// .and('contain', 'Verified disabled')
// .and('contain', 'Numeric Private')
// .and('not.contain', 'Blank')
// .and('contain', 'Amount')
// .and('contain', 'Numeric Type')
// .and('not.contain', 'Numeric name canceled')
// .and('contain', 'Numeric name public required')
// .and('contain', 'Numeric name public multiple values')
// .and('contain', 'Numeric name public unique values')
// .and('contain', 'Numeric 1')
// .and('contain', 'Numeric 2')
// .and('contain', 'Numeric 3')
// .and('contain', 'Numeric 4')
// .and('contain', 'Numeric 5')
// .and('contain', 'Numeric 6')
// .and('contain', 'Numeric 7')
// .and('contain', 'Numeric 8')
// .and('contain', 'Numeric 9')
// .and('contain', 'Numeric 10')
// })
// })
})

View File

@ -276,13 +276,6 @@ Return if field is key
Return the mask
**Returns:** string
### `function get_privacy()`
Return the privacy type
**Returns:** string
### `function get_default_value()`

View File

@ -1,4 +1,5 @@
* everything auto draft
* post_meta of deleted fields
* post_meta of deleted instaces of a multiple compound Field. post_meta of a field that is child of a compound field, but which the ID does not appear in any array of a compound field meta_value
* post_meta of deleted instaces of a multiple compound Field. post_meta of a field that is child of a compound field, but which the ID does not appear in any array of a compound field meta_value
* orphan terms (with taxonomy that does not exist)

View File

@ -24,7 +24,7 @@ This layer is based on a Repository pattern. Each entity Tainacan deals with hav
Repositories are the classes that comunicate with the database and know where everything is stored and how to find things. It is a singleton class, so it have only one instance available to be used by any part of the application.
```PHP
$fields_repo = Tainacan\Repositories\Fields::getInstance();
$fields_repo = Tainacan\Repositories\Fields::get_instance();
```
Entities classes are the representation of the individual of each repository.
@ -46,7 +46,7 @@ Tainacan will automatically map the values of the attributes to and from where t
When you want to fetch entities from the database, this abstraction layer steps aside and let you use all the power and flexibility of `WP_Query`, which you know and love. For example:
```PHP
Repositories\Fields::getInstance()->fetch('s=test');
Repositories\Fields::get_instance()->fetch('s=test');
```
The `fetch` method from the repositories accept exactly the same arguments accepted by `WP_Query` and uses it internally. In fact, you could use `WP_Query` directly if you prefer, but using the repository class gives you some advantages. You dont have to know the name of the post type, you can also fetch by some mapped attribute calling it directly, withour having to use `meta_query` (or even know wether a property is stored as a post attribute or post_meta). See more details in the Fetch section below.
@ -68,7 +68,7 @@ $collection = new Tainacan\Entities\Collection($collection_id);
This will have the same effect as calling the `fetch` method from the repository passing an integer as argument. THe repository will assume it is the collection ID.
```PHP
$collection = Tainacan\Repositories\Collections::getInstance()->fetch($collection_id);
$collection = Tainacan\Repositories\Collections::get_instance()->fetch($collection_id);
```
### Fethcing many individuals
@ -80,8 +80,8 @@ To fetch collections (or any other entity) based on a query search, you may call
Examples:
```PHP
$repo = Tainacan\Repositories\Collections::getInstance();
$items_repo = Tainacan\Repositories\Collections::getInstance();
$repo = Tainacan\Repositories\Collections::get_instance();
$items_repo = Tainacan\Repositories\Collections::get_instance();
$collections = $repo->fetch(); // get all public collections (or any private collections current user can view. It works exactly the same way WP_Query)
@ -106,7 +106,7 @@ $items = $items_repo->fetch([
Note that you can use the mapped attribute names to build your query, but it is just fine if you want to use the native WordPress names. The same can be achievied with attributes stored as post_meta:
```PHP
$repo = Tainacan\Repositories\Fields::getInstance();
$repo = Tainacan\Repositories\Fields::get_instance();
$fields = $repo->fetch([
'required' => 'yes'
@ -143,7 +143,7 @@ However, before insertion, you must validate the entity, calling the `validate()
So this is a typical routine for creating an entity:
```PHP
$collectionsRepo = \Tainacan\Repositories\Collections::getInstance();
$collectionsRepo = \Tainacan\Repositories\Collections::get_instance();
$collection = new \Tainacan\Entities\Collection();
$collection->set_name('New Collection');
@ -187,7 +187,7 @@ $itemMetadada = new \Tainacan\Entities\ItemMetadataEntity($item, $field);
$itemMetadata->set_value('Red');
if ($itemMetadata->validate()) {
$ItemMetadataRepo = \Tainacan\Repositories\ItemMetadata::getInstance();
$ItemMetadataRepo = \Tainacan\Repositories\ItemMetadata::get_instance();
$ItemMetadata = $ItemMetadataRepo->insert($ItemMetadata);
} else {
$errors = $ItemMetadata->get_errors();
@ -313,7 +313,7 @@ $item->can_edit();
So now you know how to check the permision when a user wants to update an item. Here is the complete code:
```PHP
$collectionsRepo = \Tainacan\Repositories\Collections::getInstance();
$collectionsRepo = \Tainacan\Repositories\Collections::get_instance();
$collection = new \Tainacan\Entities\Collection(23);
if ($collection->can_edit()) {

View File

@ -21,6 +21,14 @@ Items are the actual content of yout repository. The painting, the film, the boo
In WordPress language, each item is a post and its post type represents its collection.
### Document
Document is the main information of the item. It is the object which all metadata refer to. Tainacan accepts 3 different document types:
* Attachment: A file attached to the item. An image, video, pdf, audio or other media file.
* URL: An URL pointing to an external website or file. It can be a general website, a specific file, or media services. In the case of media services, Tainacan recognizes addresses and displays the appropriate player, using [oEmbed](https://oembed.com/)
* Text: A plain text, stored directly in the database, the user can type upon creating or editing an item
## Fields
Every collection have a set of fields. They are the description of the items of this collection.

View File

@ -139,7 +139,6 @@ A REST API for Tainacan Plugin. This API uses the Wordpress REST API.
"collection_key": "string",
"multiple": "string",
"cardinality": "string",
"privacy": "string",
"mask": "string",
"default_value": "string",
"field_type_options": "string",

View File

@ -39,7 +39,8 @@ cd -
# cypress beginning
if [ ${SKIP_HEAD} = "0" ]
then
./node_modules/.bin/cypress run --config baseUrl=$wp_url --record --key $cy_record_key
# ./node_modules/.bin/cypress run --config baseUrl=$wp_url --record --key $cy_record_key
./node_modules/.bin/cypress run --spec cypress/integration/repository/collection/field/field_text_spec.js --config baseUrl=$wp_url
else
./node_modules/.bin/cypress open --config baseUrl=$wp_url
fi

View File

@ -45,6 +45,7 @@
margin: 0 auto;
position: relative;
overflow-y: auto;
height: 100%;
@media screen and (max-width: 769px) {
& {
@ -59,15 +60,21 @@
.is-secondary-content {
padding: 0px;
margin: 78px auto 0 auto;
margin: $header-height auto 0 auto;
position: relative;
overflow-y: auto;
height: calc(100% - 58px);
@media screen and (max-width: 769px) {
& {
overflow-y: visible;
}
}
.columns {
margin-left: 0px;
margin-right: 0px;
}
}
</style>

View File

@ -8,7 +8,7 @@ class Admin {
private $menu_slug = 'tainacan_admin';
private static $instance = null;
public static function getInstance() {
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
@ -110,11 +110,11 @@ class Admin {
function get_admin_js_localization_params() {
global $TAINACAN_BASE_URL;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$tainacan_admin_i18n = require( 'tainacan-admin-i18n.php' );

View File

@ -147,7 +147,7 @@
mixins: [ wpAjax ],
data(){
return {
categoryId: Number,
categoryId: String,
activeTab: 0,
category: null,
isLoadingCategory: false,
@ -179,12 +179,40 @@
components: {
TermsList
},
beforeRouteLeave( to, from, next ) {
let formNotSaved = false;
if (this.category.name != this.form.name)
formNotSaved = true;
if (this.category.description != this.form.description)
formNotSaved = true;
if (this.category.slug != this.form.slug)
formNotSaved = true;
if (this.category.allow_insert != this.form.allowInsert)
formNotSaved = true;
if (this.category.status != this.form.status)
formNotSaved = true;
if (formNotSaved) {
this.$dialog.confirm({
message: this.$i18n.get('info_warning_category_not_saved'),
onConfirm: () => {
next();
},
cancelText: this.$i18n.get('cancel'),
confirmText: this.$i18n.get('continue'),
type: 'is-secondary'
});
} else {
next()
}
},
methods: {
...mapActions('category', [
'createCategory',
'updateCategory',
'fetchCategory',
'fetchOnlySlug',
'fetchOnlySlug'
]),
...mapGetters('category',[
'getCategory',
@ -212,7 +240,7 @@
this.form.slug = this.category.slug;
this.form.description = this.category.description;
this.form.status = this.category.status;
this.allowInsert = this.category.allow_insert;
this.form.allowInsert = this.category.allow_insert;
this.isLoadingCategory = false;
this.formErrorMessage = '';

View File

@ -8,118 +8,127 @@
v-if="!isLoading"
class="tainacan-form"
label-width="120px">
<b-field
:addons="false"
:label="$i18n.get('label_status')">
<help-button
:title="$i18n.getHelperTitle('items', 'status')"
:message="$i18n.getHelperMessage('items', 'status')"/>
<b-select
id="status-select"
v-model="form.status"
:placeholder="$i18n.get('instruction_select_a_status')">
<option
:id="`status-option-${statusOption.value}`"
v-for="statusOption in statusOptions"
:key="statusOption.value"
:value="statusOption.value"
:disabled="statusOption.disabled">{{ statusOption.label }}
</option>
</b-select>
</b-field>
<!-- Thumbnail -------------------------------- -->
<b-field :label="$i18n.get('label_image')">
<div class="thumbnail-field">
<b-upload
v-if="item.featured_image == undefined || item.featured_image == false"
v-model="thumbnail"
drag-drop
@input="uploadThumbnail($event)">
<div class="content has-text-centered">
<p>
<b-icon
icon="upload"/>
</p>
<p>{{ $i18n.get('instruction_image_upload_box') }}</p>
</div>
</b-upload>
<div v-else>
<figure class="image is-128x128">
<img
:alt="$i18n.get('label_thumbnail')"
:src="item.featured_image">
</figure>
<div class="thumbnail-buttons-row">
<b-upload
model="thumbnail"
@input="uploadThumbnail($event)">
<a
id="button-edit"
:aria-label="$i18n.get('label_button_edit_thumb')"><b-icon icon="pencil"/></a>
</b-upload>
<a
id="button-delete"
:aria-label="$i18n.get('label_button_delete_thumb')"
@click="deleteThumbnail()"><b-icon icon="delete"/></a>
</div>
</div>
</div>
</b-field>
<!-- Fields from Collection-------------------------------- -->
<tainacan-form-item
v-for="(field, index) in fieldList"
:key="index"
:field="field"/>
<!-- Attachments ------------------------------------------ -->
<div class="columns is-multiline">
<div class="column is-4">
<div class="columns">
<div class="column is-narrow">
<!-- Thumbnail -------------------------------- -->
<b-field :label="$i18n.get('label_image')">
<b-upload
v-model="form.files"
multiple
drag-drop
@input="uploadAttachment($event)">
<section class="section">
<div class="thumbnail-field">
<b-upload
v-if="item.featured_image == undefined || item.featured_image == false"
v-model="thumbnail"
drag-drop
@input="uploadThumbnail($event)">
<div class="content has-text-centered">
<p>
<b-icon
icon="upload"
size="is-large"/>
<b-icon
icon="upload"/>
</p>
<p>{{ $i18n.get('instruction_image_upload_box') }}</p>
</div>
</section>
</b-upload>
</b-field>
<div class="uploaded-files">
<div
v-for="(file, index) in form.files"
:key="index">
<span class="tag is-primary">
{{ file.name }}
<button
class="delete is-small"
type="button"
@click="deleteFile(index)"/>
</span>
<!-- <progress class="progress is-secondary" value="15" max="100">30%</progress> -->
</b-upload>
<div v-else>
<figure class="image is-128x128">
<img
:alt="$i18n.get('label_thumbnail')"
:src="item.featured_image">
</figure>
<div class="thumbnail-buttons-row">
<b-upload
model="thumbnail"
@input="uploadThumbnail($event)">
<a
id="button-edit"
:aria-label="$i18n.get('label_button_edit_thumb')"><b-icon icon="pencil"/></a>
</b-upload>
<a
id="button-delete"
:aria-label="$i18n.get('label_button_delete_thumb')"
@click="deleteThumbnail()"><b-icon icon="delete"/></a>
</div>
</div>
</div>
</div>
</b-field>
<!-- Attachments ------------------------------------------ -->
<div class="columns is-multiline">
<div class="column is-4">
<b-field :label="$i18n.get('label_image')">
<b-upload
v-model="form.files"
multiple
drag-drop
@input="uploadAttachment($event)">
<section class="section">
<div class="content has-text-centered">
<p>
<b-icon
icon="upload"
size="is-large"/>
</p>
<p>{{ $i18n.get('instruction_image_upload_box') }}</p>
</div>
</section>
</b-upload>
</b-field>
<div class="uploaded-files">
<div
v-for="(file, index) in form.files"
:key="index">
<span class="tag is-primary">
{{ file.name }}
<button
class="delete is-small"
type="button"
@click="deleteFile(index)"/>
</span>
<!-- <progress class="progress is-secondary" value="15" max="100">30%</progress> -->
</div>
</div>
</div>
</div>
<div
class="column is-narrow"
v-for="(attachment, index) of item.attachments"
:key="index">
<figure class="image is-128x128">
<img
:alt="attachment.title"
:src="attachment.url">
</figure>
</div>
</div>
<div class="column">
<!-- Status -------------------------------- -->
<b-field
:addons="false"
:label="$i18n.get('label_status')">
<help-button
:title="$i18n.getHelperTitle('items', 'status')"
:message="$i18n.getHelperMessage('items', 'status')"/>
<b-select
id="status-select"
v-model="form.status"
:placeholder="$i18n.get('instruction_select_a_status')">
<option
:id="`status-option-${statusOption.value}`"
v-for="statusOption in statusOptions"
:key="statusOption.value"
:value="statusOption.value"
:disabled="statusOption.disabled">{{ statusOption.label }}
</option>
</b-select>
</b-field>
<!-- Fields from Collection-------------------------------- -->
<tainacan-form-item
v-for="(field, index) in fieldList"
:key="index"
:field="field"/>
</div>
<div
class="column is-narrow"
v-for="(attachment, index) of item.attachments"
:key="index">
<figure class="image is-128x128">
<img
:alt="attachment.title"
:src="attachment.url">
</figure>
</div>
</div>
<div class="field is-grouped form-submit">
<div class="control">
<button
@ -133,7 +142,7 @@
id="button-submit-item-creation"
@click.prevent="onSubmit"
class="button is-success"
:disabled="formHasErrors">{{ $i18n.get('save') }}</button>
>{{ $i18n.get('save') }}</button>
</div>
</div>
<p class="help is-danger">{{ formErrorMessage }}</p>
@ -214,14 +223,10 @@ export default {
})
.catch((errors) => {
for (let error of errors.errors) {
for (let attribute of Object.keys(error)){
//this.editFormErrors[attribute] = error[attribute];
this.$console.log(error);
eventBus.errors.push({ field_id: 7031, errors: error[attribute]});
for (let field of Object.keys(error)){
eventBus.errors.push({ field_id: field, errors: error[field]});
}
}
this.$console.log(eventBus.errors);
this.formErrorMessage = errors.error_message;
this.isLoading = false;
@ -267,7 +272,8 @@ export default {
});
},
cancelBack(){
this.$router.push(this.$routerHelper.getCollectionPath(this.collectionId));
this.$console.log(this.fieldList);
//this.$router.push(this.$routerHelper.getCollectionPath(this.collectionId));
},
uploadAttachment($event) {
@ -317,7 +323,15 @@ export default {
return this.getFields();
},
formHasErrors(){
return eventBus.errors.length > 0;
// for (let field of this.fieldList) {
// if (field.field.required == 'yes' &&
// (field.value == '' || field.value == undefined) &&
// this.form.status == 'publish') {
// return true;
// }
// }
return false;
}
},
created(){

View File

@ -6,13 +6,11 @@
<b-field
:addons="false"
:type="editForm.name == '' ? 'is-danger' : ''"
:message="editForm.name == '' ? $i18n.get('info_name_is_required') : ''">
:type="(formErrors.name != '' && formErrors.name != undefined) ? 'is-danger' : ''"
:message="formErrors.name">
<label class="label">
{{ $i18n.get('label_name') }}
<span
class="required-term-asterisk"
:class="editForm.name == '' ? 'is-danger' : ''">*</span>
<span class="required-term-asterisk">*</span>
<help-button
:title="$i18n.getHelperTitle('terms', 'name')"
:message="$i18n.getHelperMessage('terms', 'name')"/>
@ -22,7 +20,10 @@
name="name"/>
</b-field>
<b-field :addons="false">
<b-field
:addons="false"
:type="formErrors['description'] != '' && formErrors['description'] != undefined ? 'is-danger' : ''"
:message="formErrors['description']">
<label class="label">
{{ $i18n.get('label_description') }}
<help-button
@ -47,8 +48,7 @@
<div class="control">
<button
class="button is-success"
type="submit"
:disabled="editForm.name == '' || editForm.name == undefined">
type="submit">
{{ $i18n.get('save') }}
</button>
</div>
@ -61,6 +61,11 @@ import { mapActions, mapGetters } from 'vuex';
export default {
name: 'TermEditionForm',
data () {
return {
formErrors: {}
}
},
props: {
editForm: Object,
categoryId: ''
@ -84,11 +89,16 @@ export default {
})
.then(() => {
this.editForm = {};
this.formErrors = {};
this.$emit('onEditionFinished');
})
.catch((error) => {
.catch((errors) => {
for (let error of errors.errors) {
for (let field of Object.keys(error)){
this.$set(this.formErrors, field, (this.formErrors[field] != undefined ? this.formErrors[field] : '') + error[field] + '\n');
}
}
this.$emit('onErrorFound');
this.$console.log(error);
});
} else {
@ -101,11 +111,16 @@ export default {
})
.then(() => {
this.editForm.saved = true;
this.formErrors = {};
this.$emit('onEditionFinished');
})
.catch((error) => {
.catch((errors) => {
for (let error of errors.errors) {
for (let field of Object.keys(error)){
this.$set(this.formErrors, field, (this.formErrors[field] != undefined ? this.formErrors[field] : '') + error[field] + '\n');
}
}
this.$emit('onErrorFound');
this.$console.log(error);
});
}
},

View File

@ -9,6 +9,7 @@
@click="deleteSelectedCollections()"><span>{{ $i18n.get('instruction_delete_selected_collections') }} </span><b-icon icon="delete"/></button>
</b-field>
<b-table
v-if="totalCollections > 0"
ref="collectionTable"
:data="collections"
:checked-rows.sync="selectedCollections"
@ -100,27 +101,28 @@
icon="delete"/></a>
</b-table-column>
</template>
</b-table>
<!-- Empty state image -->
<template slot="empty">
<section class="section">
<div class="content has-text-grey has-text-centered">
<p>
<b-icon
<!-- Empty state image -->
<div v-if="!totalCollections || totalCollections <= 0">
<section class="section">
<div class="content has-text-grey has-text-centered">
<p>
<b-icon
icon="inbox"
size="is-large"/>
</p>
<p>{{ $i18n.get('info_no_collection_created') }}</p>
<router-link
tag="button"
class="button is-primary"
:to="{ path: $routerHelper.getNewCollectionPath() }">
{{ $i18n.getFrom('collections', 'new_item') }}
</router-link>
</div>
</section>
</template>
</b-table>
</p>
<p>{{ $i18n.get('info_no_collection_created') }}</p>
<router-link
id="button-create-collection"
tag="button"
class="button is-primary"
:to="{ path: $routerHelper.getNewCollectionPath() }">
{{ $i18n.getFrom('collections', 'new_item') }}
</router-link>
</div>
</section>
</div>
</div>
</template>
@ -157,7 +159,7 @@ export default {
position: 'is-bottom',
type: 'is-secondary',
queue: true
})
});
for (let i = 0; i < this.selectedCollections.length; i++) {
if (this.selectedCollections[i].id == this.collectionId)
this.selectedCollections.splice(i, 1);

View File

@ -13,11 +13,9 @@
ref="eventsTable"
:data="events"
:checked-rows.sync="selectedEvents"
checkable
:loading="isLoading"
hoverable
striped
selectable
backend-sorting>
<template slot-scope="props">
@ -52,8 +50,8 @@
<b-table-column
class="row-creation"
tabindex="0"
:aria-label="$i18n.get('label_creation') + ': ' + props.row.creation"
:label="$i18n.get('label_creation')"
:aria-label="$i18n.get('label_who_when') + ': ' + props.row.creation"
:label="$i18n.get('label_who_when')"
property="by"
show-overflow-tooltip
field="props.row.by">
@ -114,7 +112,7 @@
events: Array
},
methods: {
...mapActions('events', [
...mapActions('event', [
'approve',
'notApprove'
])

View File

@ -71,7 +71,7 @@
</a>
</span>
</div>
<div v-if="choosenField.name == filter.name && openedFilterId == ''">
<div v-if="choosenField.id == filter.id && openedFilterId == ''">
<form class="tainacan-form">
<b-field :label="$i18n.get('label_filter_type')">
<b-select
@ -116,11 +116,10 @@
</draggable>
</div>
<div class="column available-fields-area">
<div
class="field"
v-if="availableFieldList.length > 0">
<div class="field" >
<h3 class="label"> {{ $i18n.get('label_available_field_types') }}</h3>
<draggable
<draggable
v-if="availableFieldList.length > 0"
:list="availableFieldList"
:options="{
sort: false,
@ -136,21 +135,25 @@
<span class="field-name">{{ field.name }}</span>
</div>
</draggable>
</div>
<div
v-else
class="field is-grouped-centered">
<h3 class="label"> {{ $i18n.get('label_available_field_types') }}</h3>
<div>
{{ $i18n.get('info_there_is_no_field' ) }}
</div>
<div class="control">
<router-link
:to="$routerHelper.getNewFieldPath()"
tag="button"
class="button is-secondary is-centered">
{{ $i18n.getFrom('fields', 'new_item') }}</router-link>
</div>
<section
v-else
class="field is-grouped-centered section">
<div class="content has-text-gray has-text-centered">
<p>
<b-icon
icon="format-list-checks"
size="is-large"/>
</p>
<p>{{ $i18n.get('info_there_is_no_field' ) }}</p>
<router-link
id="button-create-field"
:to="isRepositoryLevel ? $routerHelper.getNewFieldPath() : $routerHelper.getNewCollectionFieldPath(collectionId)"
tag="button"
class="button is-secondary is-centered">
{{ $i18n.getFrom('fields', 'new_item') }}</router-link>
</div>
</section>
</div>
</div>
</div>
@ -259,7 +262,6 @@ export default {
this.addNewFilter(fieldType, lastIndex);
},
addNewFilter(choosenField, newIndex) {
this.$console.log(choosenField);
this.choosenField = choosenField;
this.newIndex = newIndex;
this.openedFilterId = '';
@ -342,7 +344,7 @@ export default {
// Opening collapse
} else {
this.$console.log(this.choosenField);
if (this.openedFilterId == '' && this.choosenField.id != undefined) {
this.availableFieldList.push(this.choosenField);
this.choosenField = {};
@ -417,7 +419,7 @@ export default {
this.isLoadingFilterTypes = false;
});
this.fetchFilters({collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel})
this.fetchFilters({collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel, isContextEdit: true })
.then(() => {
this.isLoadingFilters = false;
// Needs to be done after activeFilterList exists to compare and remove chosen fields.

View File

@ -26,18 +26,17 @@
v-for="(column, index) in tableFields"
:key="index"
:custom-key="column.slug"
:label="column.label"
:label="column.name"
:visible="column.visible"
:width="column.field == 'row_actions' ? 78 : column.field == 'featured_image' ? 55 : undefined ">
<router-link
tag="span"
class="clickable-row"
:to="{path: $routerHelper.getItemPath(collectionId, props.row.id)}">
<template v-if="column.field != 'featured_image' && column.field != 'row_actions'">
{{ showValue( props.row.metadata[column.slug] ) }}
</template>
</router-link>
<template>
<span
class="clickable-row"
@click.prevent="goToItemPage(props.row.id)"
v-if="column.field != 'featured_image' && column.field != 'row_actions'"
v-html="renderMetadata( props.row.metadata[column.slug] )" />
</template>
<template v-if="column.field == 'featured_image'">
<router-link
@ -63,29 +62,8 @@
icon="delete"/></a>
</template>
</b-table-column>
</template>
<!-- Empty state image -->
<template slot="empty">
<section class="section">
<div class="content has-text-grey has-text-centered">
<p>
<b-icon
icon="inbox"
size="is-large"/>
</p>
<p>{{ $i18n.get('info_no_item_created') }}</p>
<router-link
id="button-create"
tag="button"
class="button is-primary"
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">
{{ $i18n.getFrom('items', 'new_item') }}
</router-link>
</div>
</section>
</template>
</b-table>
</b-table>
</div>
</template>
@ -179,20 +157,12 @@ export default {
goToItemEditPage(itemId) {
this.$router.push(this.$routerHelper.getItemEditPath(this.collectionId, itemId));
},
showValue( metadata ){
renderMetadata( metadata ){
if( ! metadata || metadata.value === false || metadata.value == undefined || metadata.value == '' )
if( !metadata )
return '';
if( metadata.value instanceof Array ){
let result = [];
for( let val of metadata.value ){
result.push( ( val.name ) ? val.name : val )
}
return result.join(', ');
} else {
return metadata.value.name ? metadata.value.name : metadata.value
}
else
return metadata.value_as_html;
}
}
}

View File

@ -97,37 +97,19 @@ export default {
watch: {
termsList() {
this.generateOrderedTerms();
},
categoryId() {
this.loadTerms();
}
},
components: {
TermEditionForm
},
beforeRouteUpdate ( to, from, next ) {
let hasUnsavedForms = false;
for (let term in this.orderedTermsList) {
if (!term.saved || term.opened || term.id == 'new')
hasUnsavedForms = true;
}
if (hasUnsavedForms) {
this.$dialog.confirm({
message: this.$i18n.get('info_warning_terms_not_saved'),
onConfirm: () => {
this.onEditionCanceled();
next();
},
cancelText: this.$i18n.get('cancel'),
confirmText: this.$i18n.get('continue'),
type: 'is-secondary'
});
} else {
next()
}
},
methods: {
...mapActions('category', [
'fetchTerms',
'updateTerm',
'deleteTerm'
'deleteTerm',
'fetchTerms'
]),
...mapGetters('category',[
'getTerms'
@ -299,7 +281,8 @@ export default {
term.opened = (this.orderedTermsList[term.id].opened == undefined ? false : this.orderedTermsList[term.id].opened);
term.saved = (this.orderedTermsList[term.id].saved == undefined ? true : this.orderedTermsList[term.id].saved);
}
this.orderedTermsList.push(JSON.parse(JSON.stringify(term)));
if (term.taxonomy != null)
this.orderedTermsList.push(JSON.parse(JSON.stringify(term)));
this.buildOrderedTermsList(term.id, termDepth + 1);
}
@ -314,22 +297,26 @@ export default {
return this.termsList[originalIndex].name;
else
return term.name;
},
loadTerms() {
this.isLoadingTerms = true;
this.fetchTerms(this.categoryId)
.then(() => {
// Fill this.form data with current data.
this.isLoadingTerms = false;
this.generateOrderedTerms();
})
.catch((error) => {
this.$console.log(error);
});
}
},
created() {
this.isLoadingTerms = true;
this.fetchTerms(this.categoryId)
.then(() => {
// Fill this.form data with current data.
this.isLoadingTerms = false;
this.generateOrderedTerms();
})
.catch((error) => {
this.$console.log(error);
});
if (this.categoryId !== String) {
this.loadTerms();
}
}
}
</script>

View File

@ -23,23 +23,6 @@
</div>
<ul class="menu-list">
<li class="search-area">
<b-field>
<b-input
:placeholder="$i18n.get('search')"
type="search"
size="is-small"
icon="magnify"/>
</b-field>
<router-link
tag="a"
to="">
<b-icon
size="is-small"
icon="magnify"/> <span class="menu-text">{{ $i18n.get('advanced_search') }}</span>
</router-link>
</li>
<li class="separator"/>
<li><router-link
tag="a"
to="/collections"

View File

@ -5,7 +5,7 @@
:class="{'secondary-page': onSecondaryPage}">
<div class="level-left">
<div class="level-item">
<h1 class="has-text-weight-bold is-uppercase has-text-primary"><b-icon
<h1 class="has-text-weight-bold is-uppercase"><b-icon
size="is-small"
:icon="currentIcon"/>{{ pageTitle }}</h1>
<nav class="breadcrumbs">
@ -26,10 +26,13 @@
</div>
</div>
<div class="level-right">
<a class="level-item">
<b-icon icon="magnify"/>
</a>
<a
class="level-item"
:href="wordpressAdmin">
<b-icon icon="close"/>
<b-icon icon="wordpress"/>
</a>
</div>
</div>
@ -70,6 +73,9 @@ export default {
...mapGetters('category', [
'getCategoryName'
]),
...mapActions('event', [
'fetchEventTitle'
]),
generateViewPath() {
for (let i = 0; i < this.arrayRealPath.length; i++) {
@ -94,6 +100,11 @@ export default {
.then(categoryName => this.arrayViewPath.splice(i, 1, categoryName))
.catch((error) => this.$console.error(error));
break;
case 'events':
this.fetchEventTitle(this.arrayRealPath[i])
.then(eventName => this.arrayViewPath.splice(i, 1, eventName))
.catch((error) => this.$console.error(error));
break;
}
} else {
@ -134,7 +145,7 @@ export default {
// Tainacan Header
#tainacan-header {
background-color: $header-color;
background-color: $secondary;
height: $header-height;
max-height: $header-height;
width: 100%;
@ -145,6 +156,7 @@ export default {
right: 0;
position: absolute;
z-index: 9;
color: white;
.icon {
padding-right: 1.3em;
@ -163,7 +175,7 @@ export default {
}
&.secondary-page {
.level-item {
margin-left: 310px;
margin-left: 87px;
}
}

View File

@ -0,0 +1,283 @@
<template>
<div
id="tainacan-subheader"
class="level"
:class="{'secondary-page': onSecondaryPage}">
<div class="level-left">
<div class="level-item">
<h1 class="has-text-weight-bold is-uppercase has-text-tertiary"><b-icon
size="is-small"
:icon="currentIcon"/>{{ pageTitle }}</h1>
<nav class="breadcrumbs">
<router-link
tag="a"
:to="$routerHelper.getCollectionsPath()">{{ $i18n.get('repository') }}</router-link> >
<span
v-for="(pathItem, index) in arrayRealPath"
:key="index">
<router-link
tag="a"
:to="'/' + arrayRealPath.slice(0, index + 1).join('/')">
{{ arrayViewPath[index] }}
</router-link>
<span v-if="index != arrayRealPath.length - 1"> > </span>
</span>
</nav>
</div>
</div>
<ul class="menu-list level-right">
<li class="level-item"><router-link
tag="a"
:to="{ path: $routerHelper.getCollectionItemsPath(id, '') }"
:class="activeRoute == 'ItemPage' || activeRoute == 'CollectionItemsPage' || activeRoute == 'ItemEditionForm' || activeRoute == 'ItemCreatePage' ? 'is-active':''"
:aria-label="$i18n.get('label_collection_fields')">
<b-icon
size="is-small"
icon="file-multiple"/>
<br>
<span class="menu-text">{{ $i18n.getFrom('items', 'name') }}</span>
</router-link></li>
<li class="level-item"><router-link
tag="a"
:to="{ path: $routerHelper.getCollectionEditPath(id) }"
:class="activeRoute == 'CollectionEditionForm' ? 'is-active':''"
:aria-label="$i18n.getFrom('collections','edit_item')">
<b-icon
size="is-small"
icon="pencil"/>
<br>
<span class="menu-text">{{ $i18n.get('edit') }}</span>
</router-link></li>
<li class="level-item"><router-link
tag="a"
:to="{ path: $routerHelper.getCollectionFieldsPath(id) }"
:class="activeRoute == 'FieldsList' ? 'is-active':''"
:aria-label="$i18n.get('label_collection_fields')">
<b-icon
size="is-small"
icon="format-list-checks"/>
<br>
<span class="menu-text">{{ $i18n.getFrom('fields', 'name') }}</span>
</router-link></li>
<li class="level-item"><router-link
tag="a"
:to="{ path: $routerHelper.getCollectionFiltersPath(id) }"
:class="activeRoute == 'FiltersList' ? 'is-active':''"
:aria-label="$i18n.get('label_collection_filters')">
<b-icon
size="is-small"
icon="filter"/>
<br>
<span class="menu-text">{{ $i18n.getFrom('filters', 'name') }}</span>
</router-link></li>
</ul>
</div>
</template>
<script>
import { mapActions, mapGetters } from 'vuex';
export default {
name: 'TainacanSubheader',
data(){
return {
activeRoute: 'ItemsList',
pageTitle: '',
arrayRealPath: [],
arrayViewPath: [],
activeRouteName: '',
currentIcon: ''
}
},
props: {
id: Number
},
watch: {
'$route' (to) {
this.activeRoute = to.name;
this.onSecondaryPage = (to.params.collectionId != undefined);
this.pageTitle = this.$route.meta.title;
this.currentIcon = this.$route.meta.icon;
this.arrayRealPath = to.path.split("/");
this.arrayRealPath = this.arrayRealPath.filter((item) => item.length != 0);
this.generateViewPath();
}
},
methods: {
...mapActions('collection', [
'fetchCollectionName'
]),
...mapGetters('collection', [
'getCollectionName'
]),
...mapActions('item', [
'fetchItemTitle'
]),
...mapGetters('item', [
'getItemTitle'
]),
...mapActions('category', [
'fetchCategoryName'
]),
...mapGetters('category', [
'getCategoryName'
]),
...mapActions('event', [
'fetchEventTitle'
]),
generateViewPath() {
for (let i = 0; i < this.arrayRealPath.length; i++) {
this.arrayViewPath.push('');
if (!isNaN(this.arrayRealPath[i]) && i > 0) {
switch(this.arrayRealPath[i-1]) {
case 'collections':
this.fetchCollectionName(this.arrayRealPath[i])
.then(collectionName => this.arrayViewPath.splice(i, 1, collectionName))
.catch((error) => this.$console.error(error));
break;
case 'items':
this.fetchItemTitle(this.arrayRealPath[i])
.then(itemTitle => this.arrayViewPath.splice(i, 1, itemTitle))
.catch((error) => this.$console.error(error));
break;
case 'categories':
this.fetchCategoryName(this.arrayRealPath[i])
.then(categoryName => this.arrayViewPath.splice(i, 1, categoryName))
.catch((error) => this.$console.error(error));
break;
case 'events':
this.fetchEventTitle(this.arrayRealPath[i])
.then(eventName => this.arrayViewPath.splice(i, 1, eventName))
.catch((error) => this.$console.error(error));
break;
}
} else {
this.arrayViewPath.splice(i, 1, this.$i18n.get(this.arrayRealPath[i]));
}
}
}
},
created() {
this.activeRoute = this.$route.name;
this.onSecondaryPage = (this.$route.params.collectionId != undefined);
this.pageTitle = this.$route.meta.title;
this.currentIcon = this.$route.meta.icon;
this.arrayRealPath = this.$route.path.split("/");
this.arrayRealPath = this.arrayRealPath.filter((item) => item.length != 0);
this.generateViewPath();
}
}
</script>
<style lang="scss" scoped>
@import "../../scss/_variables.scss";
// Tainacan Header
#tainacan-subheader {
background-color: $primary-lighter;
height: $subheader-height;
max-height: $subheader-height;
width: 100%;
border-bottom: 0.5px solid #ddd;
padding: 1.0em;
margin: 0px;
vertical-align: middle;
left: 0;
right: 0;
z-index: 9;
.icon {
padding-right: 1.3em;
margin-left: -1.3em;
}
.breadcrumbs {
font-size: 0.85em;
}
.level-left {
.level-item {
display: inline-block;
margin-left: 45px;
}
}
li{
a {
color: $secondary;
text-align: center;
white-space: nowrap;
overflow: hidden;
padding: 1.0em 1.8em;
line-height: 1.5em;
border-radius: 0px;
-webkit-transition: padding 0.3s linear; /* Safari */
transition: padding 0.3s linear;
}
a:hover {
background-color: rgba(255,255,255,0.4);
color: $tertiary;
}
a.is-active {
background-color: rgba(255,255,255,0.6);
color: $tertiary;
}
.icon {
margin: 0;
padding: 0;
}
.menu-text {
opacity: 1;
visibility: visible;
transition: opacity 0.3s linear, visibility 0.3s linear;
-webkit-transition: opacity 0.3s linear, visibility 0.3s linear;
}
}
@media screen and (max-width: 769px) {
width: 100% !important;
max-width: 100% !important;
ul {
flex-flow: wrap;
display: flex;
align-items: stretch;
justify-content: space-evenly;
a {
padding: 0.5em 0.7em !important;
text-align: center;
}
.menu-text {
padding-left: 0.3em !important;
}
}
}
@media screen and (max-width: 769px) {
.level-left {
margin-left: 0px !important;
.level-item {
margin-left: 30px;
}
}
top: 206px;
margin-bottom: 0px !important;
}
}
</style>

View File

@ -1,10 +1,31 @@
<template>
<div>
<tainacan-filters-list
:query="getPostQuery()"
v-for="(filter, index) in filters"
:key="index"
:filter="filter"/>
<div v-if="filters.length > 0">
<tainacan-filter-item
:query="getPostQuery()"
v-for="(filter, index) in filters"
:key="index"
:filter="filter"/>
</div>
<section
v-else
class="is-grouped-centered section">
<div class="content has-text-gray has-text-centered">
<p>
<b-icon
icon="filter-outline"
size="is-large"/>
</p>
<p>{{ $i18n.get('info_there_is_no_filter' ) }}</p>
<router-link
id="button-create-filter"
:to="isRepositoryLevel ? $routerHelper.getNewFilterPath() : $routerHelper.getNewCollectionFilterPath(collectionId)"
tag="button"
class="button is-secondary is-centered">
{{ $i18n.getFrom('filters', 'new_item') }}</router-link>
</div>
</section>
</div>
</template>
<script>
@ -19,7 +40,7 @@
},
created(){
this.collectionId = ( this.$route.params.collectionId ) ? this.$route.params.collectionId : null;
this.fetchFilters( { collectionId: this.collectionId, isRepositoryLevel: !( this.collectionId ) })
this.fetchFilters( { collectionId: this.collectionId, isRepositoryLevel: !( this.collectionId ), isContextEdit: true })
.then( res => {
if( res && res.length > 0){
this.filters = res;

View File

@ -37,7 +37,7 @@
<script>
import { mapGetters } from 'vuex';
import { eventSearchBus } from '../../../js/event-search-bus'
import { eventSearchBus } from '../../../js/event-search-bus';
export default {
name: 'Pagination',

View File

@ -14,83 +14,76 @@
class="control"
custom>
<b-checkbox
@input="onChangeTableFields(column)"
v-model="column.visible"
:native-value="column.field">
{{ column.label }}
{{ column.name }}
</b-checkbox>
</b-dropdown-item>
</b-dropdown>
</div>
<div class="header-item">
<b-field>
<b-select :placeholder="$i18n.get('label_sorting')">
<option
v-for="(field, index) in tableFields"
:value="field"
:key="index">
{{ field.label }}
</option>
</b-select>
<button>
<b-icon icon="sort-ascending"/>
</button>
<b-select
@input="onChangeOrderBy($event)"
:placeholder="$i18n.get('label_sorting')">
<option
v-for="(field, index) in tableFields"
v-if="
field.id != undefined &&
field.field_type_object.related_mapped_prop != 'description' &&
field.field_type_object.primitive_type != 'term' &&
field.field_type_object.primitive_type != 'item' &&
field.field_type_object.primitive_type != 'compound'"
:value="field"
:key="index">
{{ field.name }}
</option>
</b-select>
<button
class="button is-small"
@click="onChangeOrder()">
<b-icon :icon="order == 'ASC' ? 'sort-ascending' : 'sort-descending'"/>
</button>
</b-field>
</div>
</span>
</template>
<script>
import { mapActions } from 'vuex';
import { mapGetters } from 'vuex';
import { eventSearchBus } from '../../../js/event-search-bus';
export default {
name: 'SearchControl',
data() {
return {
prefTableFields: []
}
},
props: {
collectionId: Number,
isRepositoryLevel: false,
tableFields: Array,
prefTableFields: Array,
tableFields: Array
},
methods: {
...mapActions('fields', [
'fetchFields'
]),
onChangeTableFields(field) {
// let prevValue = this.prefTableFields;
// let index = this.prefTableFields.findIndex(alteredField => alteredField.slug === field.slug);
// if (index >= 0) {
// prevValue[index].visible = this.prefTableFields[index].visible ? false : true;
// }
// for (let currentField of this.prefTableFields)
// this.$console.log(currentField.slug, currentField.visible);
// for (let oldField of prevValue)
// this.$console.log(oldField.slug, oldField.visible);
// this.$userPrefs.set('table_columns_' + this.collectionId, this.prefTableFields, prevValue);
computed: {
orderBy() {
return this.getOrderBy();
},
order() {
return this.getOrder();
}
},
mounted() {
this.fetchFields({ collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel, isContextEdit: false }).then((res) => {
let rawFields = res;
this.tableFields.push({ label: this.$i18n.get('label_thumbnail'), field: 'featured_image', slug: 'featured_image', visible: true });
for (let field of rawFields) {
this.tableFields.push(
{ label: field.name, field: field.description, slug: field.slug, visible: true }
);
}
this.tableFields.push({ label: this.$i18n.get('label_actions'), field: 'row_actions', slug: 'actions', visible: true });
this.prefTableFields = this.tableFields;
// this.$userPrefs.get('table_columns_' + this.collectionId)
// .then((value) => {
// this.prefTableFields = value;
// })
// .catch((error) => {
// this.$userPrefs.set('table_columns_' + this.collectionId, this.prefTableFields, null);
// });
}).catch();
methods: {
...mapGetters('search', [
'getOrderBy',
'getOrder'
]),
onChangeOrderBy(field) {
eventSearchBus.setOrderBy(field);
},
onChangeOrder() {
this.order == 'DESC' ? eventSearchBus.setOrder('ASC') : eventSearchBus.setOrder('DESC');
}
}
}
</script>

View File

@ -26,7 +26,7 @@ import FilterCategoryTaginput from '../../classes/filter-types/category/Taginput
import FilterCategorySelectbox from '../../classes/filter-types/category/Selectbox.vue';
import TaincanFormItem from '../../classes/field-types/tainacan-form-item.vue';
import TaincanFiltersList from '../../classes/filter-types/tainacan-filters-list.vue';
import TaincanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue';
// Remaining imports
import AdminPage from '../admin.vue'
@ -63,7 +63,7 @@ Vue.component('tainacan-form-relationship', FormRelationship);
Vue.component('tainacan-form-category', FormCategory);
Vue.component('tainacan-form-selectbox', FormSelectbox);
Vue.component('tainacan-form-item', TaincanFormItem);
Vue.component('tainacan-filters-list', TaincanFiltersList);
Vue.component('tainacan-filter-item', TaincanFiltersList);
/* Filters */
Vue.component('tainacan-filter-custom-interval', FilterCustomInterval);

View File

@ -12,6 +12,7 @@ import FiltersPage from '../pages/lists/filters-page.vue'
import CategoriesPage from '../pages/lists/categories-page.vue'
import CategoryPage from '../pages/singles/category-page.vue'
import EventsPage from '../pages/lists/events-page.vue'
import EventPage from '../pages/singles/event-page.vue'
// Edition Form Components
import CollectionEditionForm from '../components/edition/collection-edition-form.vue'
@ -27,7 +28,7 @@ Vue.use(VueRouter);
const i18nGet = function (key) {
let string = tainacan_plugin.i18n[key];
return (string != undefined && string != null && string != '' ) ? string : "ERROR: Invalid i18n key!";
}
};
const routes = [
{ path: '/', redirect:'/collections' },
@ -61,9 +62,10 @@ const routes = [
{ path: '/categories/:categoryId', name: 'CategoryPage', component: CategoryPage, meta: {title: i18nGet('title_category_page'), icon: 'shape'} },
{ path: '/events', name: 'EventsPage', component: EventsPage, meta: {title: i18nGet('title_events_page'), icon: 'bell'} },
{ path: '/events/:eventId', name: 'EventPage', component: EventPage, meta: {title: i18nGet('title_event_page'), icon: 'bell'} },
{ path: '*', redirect: '/'}
]
];
export default new VueRouter ({
routes,
@ -72,8 +74,8 @@ export default new VueRouter ({
return qs.parse(query);
},
stringifyQuery(query) {
var result = qs.stringify(query);
let result = qs.stringify(query);
return result ? ('?' + result) : '';
}
})
});

View File

@ -212,9 +212,15 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
getNewItemPath(collectionId) {
return '/collections/' + collectionId + '/items/new';
},
getNewCollectionFieldPath(collectionId) {
return '/collections/' + collectionId + '/fields/';
},
getNewFieldPath() {
return '/fields';
},
getNewCollectionFilterPath(collectionId) {
return '/collections/' + collectionId + '/filters/';
},
getNewFilterPath() {
return '/filters/new';
},

View File

@ -5,11 +5,12 @@
class="sub-header"
v-if="totalCategories > 0">
<div class="header-item">
<router-link
<router-link
id="button-create-category"
tag="button"
class="button is-secondary"
:to="{ path: $routerHelper.getNewCategoryPath() }">
{{ $i18n.get('new') + ' ' + $i18n.get('category') }}
{{ $i18n.getFrom('taxonomies', 'new_item') }}
</router-link>
</div>
</div>

View File

@ -1,8 +1,11 @@
<template>
<div class="primary-page page-container-small">
<div class="sub-header">
<div
class="sub-header"
v-if="totalCollections > 0">
<div class="header-item">
<router-link
id="button-create-collection"
tag="button"
class="button is-secondary"
:to="{ path: $routerHelper.getNewCollectionPath() }">
@ -11,7 +14,9 @@
</div>
</div>
<div class="columns above-subheader">
<aside class="column filters-menu">
<aside
class="column filters-menu"
v-if="totalCollections > 0">
<h3>{{ $i18n.getFrom('filters', 'name') }}</h3>
</aside>
<div class="column table-container">
@ -22,7 +27,9 @@
:collections-per-page="collectionsPerPage"
:collections="collections"/>
<!-- Footer -->
<div class="pagination-area">
<div
class="pagination-area"
v-if="totalCollections > 0">
<div class="shown-items">
{{
$i18n.get('info_showing_collections') +
@ -130,7 +137,7 @@ export default {
})
.catch(() => {
this.$userPrefs.set('collections_per_page', 12, null);
});
});
},
mounted(){
this.loadCollections();

View File

@ -73,10 +73,10 @@
EventsList
},
methods: {
...mapActions('events', [
...mapActions('event', [
'fetchEvents',
]),
...mapGetters('events', [
...mapGetters('event', [
'getEvents'
]),
onChangeEventsPerPage(value) {
@ -113,7 +113,7 @@
for (let event of eventsList)
event['by'] = this.$i18n.get('info_by') +
event['user_name'] + '<br>' + this.$i18n.get('info_date') +
moment(event['log_date'], 'YYYY-MM-DD').format('DD/MM/YYYY');
moment(event['log_date'], 'YYYY-MM-DD h:mm:ss').format('DD/MM/YYYY, hh:mm:ss');
return eventsList;
}

View File

@ -2,9 +2,12 @@
<div
class="page-container-small"
:class="{'primary-page': isRepositoryLevel}">
<div class="sub-header">
<div
class="sub-header"
v-if="items.length > 0">
<div class="header-item">
<router-link
id="button-create-item"
tag="button"
class="button is-secondary"
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">
@ -18,19 +21,41 @@
:table-fields="tableFields"
:pref-table-fields="prefTableFields"/>
</div>
<div class="columns above-subheader">
<div class="columns">
<aside class="column filters-menu">
<h3>{{ $i18n.get('filters') }}</h3>
<filters-items-list />
</aside>
<div class="column table-container">
<items-list
:collection-id="collectionId"
:table-fields="tableFields"
:items="items"
:is-loading="isLoading"/>
<!-- Pagination Footer -->
<pagination v-if="items.length > 0"/>
<div class="column">
<div class="table-container above-subheader">
<items-list
v-if="items.length > 0"
:collection-id="collectionId"
:table-fields="tableFields"
:items="items"
:is-loading="isLoading"/>
<section
v-else
class="section">
<div class="content has-text-grey has-text-centered">
<p>
<b-icon
icon="inbox"
size="is-large"/>
</p>
<p>{{ $i18n.get('info_no_item_created') }}</p>
<router-link
id="button-create-item"
tag="button"
class="button is-primary"
:to="{ path: $routerHelper.getNewItemPath(collectionId) }">
{{ $i18n.getFrom('items', 'new_item') }}
</router-link>
</div>
</section>
<!-- Pagination Footer -->
<pagination v-if="items.length > 0"/>
</div>
</div>
</div>
</div>
@ -68,6 +93,9 @@ export default {
...mapGetters('collection', [
'getItems'
]),
...mapActions('fields', [
'fetchFields'
]),
},
computed: {
items(){
@ -76,10 +104,31 @@ export default {
},
created() {
this.collectionId = this.$route.params.collectionId;
this.isRepositoryLevel = (this.collectionId == undefined);
this.isRepositoryLevel = (this.collectionId == undefined);
eventSearchBus.$on('isLoadingItems', isLoadingItems => {
this.isLoading = isLoadingItems;
});
this.fetchFields({ collectionId: this.collectionId, isRepositoryLevel: this.isRepositoryLevel, isContextEdit: false }).then((res) => {
let rawFields = res;
this.tableFields.push({ name: this.$i18n.get('label_thumbnail'), field: 'featured_image', field_type: undefined, slug: 'featured_image', id: undefined, visible: true });
for (let field of rawFields) {
this.tableFields.push(
{name: field.name, field: field.description, slug: field.slug, field_type: field.field_type, field_type_object: field.field_type_object, id: field.id, visible: true }
);
}
this.tableFields.push({ name: this.$i18n.get('label_actions'), field: 'row_actions', field_type: undefined, slug: 'actions', id: undefined, visible: true });
//this.prefTableFields = this.tableFields;
// this.$userPrefs.get('table_columns_' + this.collectionId)
// .then((value) => {
// this.prefTableFields = value;
// })
// .catch((error) => {
// this.$userPrefs.set('table_columns_' + this.collectionId, this.prefTableFields, null);
// });
}).catch();
},
mounted(){
eventSearchBus.updateStoreFromURL();
@ -93,9 +142,14 @@ export default {
@import '../../scss/_variables.scss';
.page-container-small>.columns {
margin-top: 0;
}
.sub-header {
max-height: $header-height;
height: $header-height;
max-height: $subheader-height;
height: $subheader-height;
margin-left: -$page-small-side-padding;
margin-right: -$page-small-side-padding;
margin-top: -$page-small-top-padding;
@ -103,11 +157,6 @@ export default {
padding-left: $page-small-side-padding;
padding-right: $page-small-side-padding;
border-bottom: 0.5px solid #ddd;
.header-item {
display: inline-block;
padding-right: 8em;
}
@media screen and (max-width: 769px) {
height: 60px;
@ -124,35 +173,35 @@ export default {
margin-bottom: 0;
margin-top: 0;
min-height: 100%;
height: auto;
height: auto;
}
.filters-menu {
min-width: $side-menu-width;
max-width: $side-menu-width;
background-color: $primary-lighter;
margin-left: -$page-small-side-padding;
padding: $page-small-side-padding;
.label {
font-size: 12px;
font-weight: normal;
}
.filters-menu {
min-width: $side-menu-width;
max-width: $side-menu-width;
background-color: $tainacan-input-color;
margin-left: -$page-small-side-padding;
padding: $page-small-side-padding;
.label {
font-size: 12px;
font-weight: normal;
}
}
.table-container {
margin-right: -$page-small-side-padding;
padding: 3em 2.5em;
}
@media screen and (max-width: 769px) {
.filters-menu {
display: none;
}
.table-container {
margin-right: -$page-small-side-padding;
padding: 3em 2.5em;
}
@media screen and (max-width: 769px) {
.filters-menu {
display: none;
}
.table-container {
margin-right: 0;
padding: .85em 0em;
}
margin-right: 0;
padding: .85em 0em;
}
}

View File

@ -1,14 +1,14 @@
<template>
<div class="columns is-fullheight">
<secondary-menu :id="collectionId"/>
<section class="column is-secondary-content">
<tainacan-subheader :id="collectionId"/>
<router-view class="page-container"/>
</section>
</div>
</template>
<script>
import SecondaryMenu from '../../components/navigation/secondary-menu.vue';
import TainacanSubheader from '../../components/navigation/tainacan-subheader.vue';
export default {
name: 'CollectionPage',
@ -18,7 +18,7 @@ export default {
}
},
components: {
SecondaryMenu
TainacanSubheader
},
created(){
this.collectionId = parseInt(this.$route.params.collectionId);

View File

@ -0,0 +1,88 @@
<template>
<div>
<div class="is-fullheight">
<div class="page-container primary-page">
<div class="tile is-ancestor">
<div class="tile is-parent">
<article class="tile notification is-child is-light">
<div class="content">
<div class="title">Before change</div>
<div
v-for="(diff, key) in event.log_diff"
v-if="diff.old"
:key="key">
<p/>
<div class="has-text-weight-bold is-capitalized">{{ `${key.replace('_', ' ')}:` }}</div>
<div class="content">{{ diff.old }}</div>
</div>
</div>
</article>
</div>
<div class="tile is-parent">
<article class="tile notification is-child is-light">
<div class="content">
<div class="title">What was changed</div>
<div
v-for="(diff, key) in event.log_diff"
:key="key">
<p/>
<div
class="has-text-weight-bold is-capitalized"
:class="{'has-text-success': !diff.old }">
{{ `${key.replace('_', ' ')}:` }}
</div>
<div
v-for="(d, i) in diff.new"
:key="i"
:class="{'has-text-success': diff.diff_with_index.hasOwnProperty(i) }"
class="content is-inline" >
{{ d }}
</div>
</div>
</div>
</article>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import {mapActions, mapGetters} from 'vuex';
export default {
name: 'EventPage',
data() {
return {
eventId: Number,
}
},
methods: {
...mapActions('event', [
'fetchEvent'
]),
...mapGetters('event', [
'getEvent'
])
},
computed: {
event() {
return this.getEvent();
}
},
created() {
this.eventId = parseInt(this.$route.params.eventId);
this.fetchEvent(this.eventId);
}
}
</script>
<style scoped>
</style>

View File

@ -19,7 +19,6 @@ $success: #25a189;
$success-invert: findColorInvert($success);
$separator-color: #2a6e77;
$header-color: #ececec;
$tainacan-input-color: #f0f0f0;
$draggable-border-color: #d8d8d8;
@ -54,9 +53,10 @@ $colors: map-merge($colors, $addColors);
$size-small: 0.85em; // 0.75em on Bulma.
// Tainacan Header and side menus
$header-height: 78px;
$header-height: 58px;
$subheader-height: 78px;
$side-menu-width: 222px;
$page-height: calc(100% - 78px);
$page-height: calc(100% - 58px);
// Overall Pages padding:
$page-side-padding: 4em;

View File

@ -27,7 +27,6 @@ html {
width: 100%;
z-index: 999999;
overflow-y: auto;
height: 100%;
margin: 0px !important;
font-family: $family-sans-serif;
}
@ -62,7 +61,7 @@ html {
}
.page-container-small{
padding: $page-small-top-padding $page-small-side-padding;
height: 100%;
height: calc(100% - 78px);
overflow-y: auto;
@media screen and (max-width: 769px) {
@ -83,6 +82,7 @@ html {
padding: 1em 1.2em 0.4em 1.2em;
margin-bottom: 0px;
.button {
border-width: 1px;
padding: 2px 30px !important;
}
.button.is-outlined {
@ -154,6 +154,7 @@ html {
// Some components have a different style in listing pages
.button {
border-width: 0;
border-radius: 6px !important;
font-weight: normal;
padding: 2px 15px !important;

View File

@ -133,6 +133,7 @@ return [
'label_term_without_name' => __( 'Term without name', 'tainacan' ),
'label_inherited' => __( 'Inherited', 'tainacan' ),
'label_sorting' => __( 'Sorting', 'tainacan' ),
'label_who_when' => __( 'Who and when', 'tainacan' ),
// Instructions. More complex sentences to guide user and placeholders
'instruction_dragndrop_fields_collection' => __( 'Drag and drop Fields here to Collection.', 'tainacan' ),
@ -177,9 +178,11 @@ return [
'info_warning_fields_not_saved' => __('Are you sure? There are fields not saved, changes will be lost.', 'tainacan'),
'info_warning_filters_not_saved' => __('Are you sure? There are filters not saved, changes will be lost.', 'tainacan'),
'info_no_description_provided' => __('No description provided.', 'tainacan'),
'info_warning_terms_not_saved' => __('Are you sure? There are terms not saved, changes will be lost.', 'tainacan'),
'info_warning_orphan_terms' => __('Are you sure? This term is parent of other terms. These will be converted to root terms.', 'tainacan'),
'info_there_is_no_field' => __('There is no field here.', 'tainacan' ),
'info_warning_category_not_saved' => __('Are you sure? The category is not saved, changes will be lost.', 'tainacan'),
'info_warning_terms_not_saved' => __('Are you sure? There are terms not saved, changes will be lost.', 'tainacan'),
'info_warning_orphan_terms' => __('Are you sure? This term is parent of other terms. These will be converted to root terms.', 'tainacan'),
'info_there_is_no_field' => __('There is no field here yet.', 'tainacan' ),
'info_there_is_no_filter' => __('There is no filter here yet.', 'tainacan' ),
// Tainacan Field Types
'tainacan-text' => __( 'Text', 'tainacan' ),

View File

@ -72,6 +72,7 @@ class TAINACAN_REST_Controller extends WP_REST_Controller {
* @param $request
*
* @return array
* @throws Exception
*/
protected function prepare_filters($request){
$queries = [
@ -96,7 +97,10 @@ class TAINACAN_REST_Controller extends WP_REST_Controller {
'perpage' => 'posts_per_page',
'paged' => 'paged',
'postin' => 'post__in',
'relation' => 'relation'
'relation' => 'relation',
'nopaging' => 'nopaging',
'meta_key' => 'meta_key',
'meta_type' => 'meta_type'
];
$meta_query = [
@ -380,6 +384,8 @@ class TAINACAN_REST_Controller extends WP_REST_Controller {
'slug',
'include_slugs',
'title',
'meta_value',
'meta_value_num'
),
);

View File

@ -28,7 +28,7 @@ class TAINACAN_REST_Collections_Controller extends TAINACAN_REST_Controller {
* Initialize objects after post_type register
*/
public function init_objects() {
$this->collections_repository = Repositories\Collections::getInstance();
$this->collections_repository = Repositories\Collections::get_instance();
$this->collection = new Entities\Collection();
}

View File

@ -80,7 +80,7 @@ class TAINACAN_REST_Field_Types_Controller extends TAINACAN_REST_Controller {
* @return WP_Error|WP_REST_Response
*/
public function get_items( $request ) {
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$field_types = $Tainacan_Fields->fetch_field_types('NAME');

View File

@ -23,10 +23,10 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
* @throws Exception
*/
public function init_objects() {
$this->field_repository = Repositories\Fields::getInstance();
$this->item_metadata_repository = Repositories\Item_Metadata::getInstance();
$this->item_repository = Repositories\Items::getInstance();
$this->collection_repository = Repositories\Collections::getInstance();
$this->field_repository = Repositories\Fields::get_instance();
$this->item_metadata_repository = Repositories\Item_Metadata::get_instance();
$this->item_repository = Repositories\Items::get_instance();
$this->collection_repository = Repositories\Collections::get_instance();
}
/**
@ -262,14 +262,15 @@ class TAINACAN_REST_Fields_Controller extends TAINACAN_REST_Controller {
public function prepare_item_for_response( $item, $request ) {
if(!empty($item)){
$item_arr = $item->__toArray();
$item_arr['field_type_object'] = $item->get_field_type_object()->__toArray();
if($request['context'] === 'edit'){
$item_arr['current_user_can_edit'] = $item->can_edit();
ob_start();
$item->get_field_type_object()->form();
$form = ob_get_clean();
$item_arr['edit_form'] = $form;
$item_arr['field_type_object'] = $item->get_field_type_object()->__toArray();
$item_arr['enabled'] = $item->get_enabled_for_collection();
}

View File

@ -65,7 +65,7 @@ class TAINACAN_REST_Filter_Types_Controller extends TAINACAN_REST_Controller {
* @return WP_Error|WP_REST_Response
*/
public function get_items( $request ) {
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$filter_types = $Tainacan_Filters->fetch_filter_types('NAME');

View File

@ -28,11 +28,11 @@ class TAINACAN_REST_Filters_Controller extends TAINACAN_REST_Controller {
*/
public function init_objects() {
$this->collection = new Entities\Collection();
$this->collection_repository = Repositories\Collections::getInstance();
$this->collection_repository = Repositories\Collections::get_instance();
$this->field_repository = Repositories\Fields::getInstance();
$this->field_repository = Repositories\Fields::get_instance();
$this->filter_repository = Repositories\Filters::getInstance();
$this->filter_repository = Repositories\Filters::get_instance();
}
public function register_routes() {

View File

@ -23,10 +23,10 @@ class TAINACAN_REST_Item_Metadata_Controller extends TAINACAN_REST_Controller {
*/
public function init_objects() {
$this->field = new Entities\Field();
$this->field_repository = Repositories\Fields::getInstance();
$this->item_metadata_repository = Repositories\Item_Metadata::getInstance();
$this->item_repository = Repositories\Items::getInstance();
$this->collection_repository = Repositories\Collections::getInstance();
$this->field_repository = Repositories\Fields::get_instance();
$this->item_metadata_repository = Repositories\Item_Metadata::get_instance();
$this->item_repository = Repositories\Items::get_instance();
$this->collection_repository = Repositories\Collections::get_instance();
}
/**

View File

@ -30,10 +30,10 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_REST_Controller {
* Initialize objects after post_type register
*/
public function init_objects() {
$this->items_repository = Repositories\Items::getInstance();
$this->items_repository = Repositories\Items::get_instance();
$this->item = new Entities\Item();
$this->item_metadata = Repositories\Item_Metadata::getInstance();
$this->collections_repository = Repositories\Collections::getInstance();
$this->item_metadata = Repositories\Item_Metadata::get_instance();
$this->collections_repository = Repositories\Collections::get_instance();
}
/**
@ -103,6 +103,8 @@ class TAINACAN_REST_Items_Controller extends TAINACAN_REST_Controller {
$item_array['metadata'][$slug]['name'] = $field->get_name();
$item_array['metadata'][$slug]['value'] = $item_metadata_array['value'];
$item_array['metadata'][$slug]['value_as_html'] = $item_metadata_array['value_as_html'];
$item_array['metadata'][$slug]['value_as_string'] = $item_metadata_array['value_as_string'];
$item_array['metadata'][$slug]['multiple'] = $field->get_multiple();
}

View File

@ -20,7 +20,7 @@ class TAINACAN_REST_Logs_Controller extends TAINACAN_REST_Controller {
}
public function init_objects(){
$this->logs_repository = Repositories\Logs::getInstance();
$this->logs_repository = Repositories\Logs::get_instance();
$this->log = new Entities\Log();
}
@ -64,7 +64,22 @@ class TAINACAN_REST_Logs_Controller extends TAINACAN_REST_Controller {
*/
public function prepare_item_for_response( $item, $request ) {
if(!empty($item)){
return $item->__toArray();
if(!isset($request['fetch_only'])) {
$item_array = $item->__toArray();
if ( $request['context'] === 'edit' ) {
$log_diff = $item->diff();
$item_array['log_diff'] = $log_diff;
}
return $item_array;
}
$attributes_to_filter = $request['fetch_only'];
return $this->filter_object_by_attributes($item, $attributes_to_filter);
}
return $item;
@ -136,8 +151,12 @@ class TAINACAN_REST_Logs_Controller extends TAINACAN_REST_Controller {
public function get_item_permissions_check( $request ) {
$log = $this->logs_repository->fetch($request['log_id']);
if($log instanceof Entities\Log){
return $log->can_read();
if(($log instanceof Entities\Log)) {
if('edit' === $request['context'] && !$log->can_read()) {
return false;
}
return true;
}
return false;

View File

@ -23,7 +23,7 @@ class TAINACAN_REST_Taxonomies_Controller extends TAINACAN_REST_Controller {
*/
public function init_objects() {
$this->taxonomy = new Entities\Taxonomy();
$this->taxonomy_repository = Repositories\Taxonomies::getInstance();
$this->taxonomy_repository = Repositories\Taxonomies::get_instance();
}
public function register_routes() {

View File

@ -25,9 +25,9 @@ class TAINACAN_REST_Terms_Controller extends TAINACAN_REST_Controller {
*/
public function init_objects() {
$this->term = new Entities\Term();
$this->terms_repository = Repositories\Terms::getInstance();
$this->terms_repository = Repositories\Terms::get_instance();
$this->taxonomy = new Entities\Taxonomy();
$this->taxonomy_repository = Repositories\Taxonomies::getInstance();
$this->taxonomy_repository = Repositories\Taxonomies::get_instance();
}
public function register_routes() {

View File

@ -272,7 +272,7 @@ class Capabilities {
];
private static $instance = null;
public static function getInstance()
public static function get_instance()
{
if(!isset(self::$instance))
{
@ -392,7 +392,7 @@ class Capabilities {
}
}
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
foreach ($collections as $collection) {
$this->set_items_capabilities($collection, $defaults_caps);

View File

@ -87,6 +87,8 @@ class Collection extends Entity {
$cpt_labels = $repository->get_cpt_labels();
$cpt_labels['menu_name'] = $this->get_name();
$cpt_labels['name'] = $this->get_name();
$cpt_labels['singular_name'] = $this->get_name();
$cpt_slug = $this->get_db_identifier();
$capabilities = $this->get_items_capabilities();
@ -373,7 +375,7 @@ class Collection extends Entity {
* @throws \Exception
*/
function get_fields() {
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
return $Tainacan_Fields->fetch_by_collection( $this, [], 'OBJECT' );
}

View File

@ -128,7 +128,7 @@ class Entity {
public function get_repository()
{
$namespace = '\Tainacan\Repositories\\'.$this->repository;
$repository = $namespace::getInstance();
$repository = $namespace::get_instance();
return $repository;
}
@ -219,13 +219,13 @@ class Entity {
foreach ($prop_value as $val) {
if (!$validation->validate($val)) {
$this->add_error($this->get_id() .' '. $prop, $message);
$this->add_error($prop, $message);
$is_valid = false;
}
}
} else {
if (!$validation->validate($prop_value)) {
$this->add_error($this->get_id() .' '. $prop, $message);
$this->add_error($prop, $message);
$is_valid = false;
}
}
@ -275,6 +275,7 @@ class Entity {
public function add_error($type, $message) {
$this->errors[] = [$type => $message];
$this->set_validated(false);
}
/**

View File

@ -19,7 +19,6 @@ class Field extends Entity {
$cardinality,
$collection_key,
$mask,
$privacy,
$default_value,
$field_type,
$field_type_options;
@ -131,15 +130,6 @@ class Field extends Entity {
return $this->get_mapped_property('mask');
}
/**
* Return the privacy type
*
* @return string
*/
function get_privacy(){
return $this->get_mapped_property('privacy');
}
/**
* Return the field default value
*
@ -301,16 +291,6 @@ class Field extends Entity {
$this->set_mapped_property('mask', $value);
}
/**
* Set privacy
*
* @param [string] $value
* @return void
*/
function set_privacy( $value ){
$this->set_mapped_property('privacy', $value);
}
/**
* Set default value
*
@ -414,6 +394,38 @@ class Field extends Entity {
if (false === $is_valid)
return false;
// You cant have a multiple field inside a compound field (except category)
if ($this->get_parent() > 0) {
if ( $this->is_multiple() && $this->get_field_type_object()->get_primitive_type() != 'term') {
$this->add_error($this->get_id(), __('Compound fields do not support fields with multiple values (except categories)', 'tainacan'));
return false;
}
}
// You cant have a category field inside a multiple compound field
if ( $this->get_parent() > 0 && $this->get_field_type_object()->get_primitive_type() == 'term' ) {
$parent_field = new \Tainacan\Entities\Field($this->get_parent());
if ( $parent_field->is_multiple() ) {
$this->add_error($this->get_id(), __('Category fields can not be used inside Compound field with multiple values', 'tainacan'));
return false;
}
}
if ( $this->get_field_type() == 'Tainacan\Field_Types\Compound' && $this->is_multiple() ) {
$Tainacan_fields = \Tainacan\Repositories\Fields::get_instance();
$children = $Tainacan_fields->fetch(
[
'parent' => $this->get_id(),
'field_type' => 'Tainacan\Field_Types\Category',
'post_status' => 'any'
]
, 'OBJECT');
if ( sizeof($children) > 0 ) {
$this->add_error($this->get_id(), __('Category fields can not be used inside Compound field with multiple values', 'tainacan'));
return false;
}
}
$fto = $this->get_field_type_object();
if (is_object($fto)) {

View File

@ -16,6 +16,14 @@ class Item_Metadata_Entity extends Entity {
*/
protected $repository = 'Item_Metadata';
protected
$item,
$field,
$parent_meta_id,
$meta_id,
$has_value,
$value;
/**
*
* @param Item $item Item Entity
@ -37,26 +45,103 @@ class Item_Metadata_Entity extends Entity {
}
/**
* Get the value as a HTML string, with markup and links
* @return string
*/
public function get_value_as_html(){
$field = $this->get_field();
if (is_object($field)) {
$fto = $field->get_field_type_object();
if (is_object($fto)) {
if ( method_exists($fto, 'get_value_as_html') ) {
return $fto->get_value_as_html($this);
}
}
}
$value = $this->get_value();
$return = '';
if ( $this->is_multiple() ) {
$total = sizeof($value);
$count = 0;
foreach ($value as $v) {
$return .= (string) $v;
$count ++;
if ($count <= $total)
$return .= ', ';
}
} else {
$return = (string) $value;
}
public function __toString(){
return 'Hello, I\'m the Item Field Entity';
return $return;
}
/**
* Get the value as a plain text string
* @return string
*/
public function get_value_as_string() {
return strip_tags($this->get_value_as_html());
}
/**
* Get value as an array
* @return [type] [description]
*/
public function get_value_as_array() {
$value = $this->get_value();
if ( $this->is_multiple() ) {
$return = [];
foreach ($value as $v) {
if ( $v instanceof Term || $v instanceof ItemMetadataEntity ) {
$return[] = $v->__toArray();
} else {
$return[] = $v;
}
}
} else {
$return = '';
if ( $value instanceof Term || $value instanceof ItemMetadataEntity ) {
$return = $value->__toArray();
} else {
$return = $value;
}
}
return $return;
}
/**
* Convert the object to an Array
* @return array the representation of this object as an array
*/
public function __toArray(){
$value = $this->get_value();
if(is_array($value) && $value[0] instanceof Term){
$values_arr = [];
foreach ($value as $val){
$values_arr[] = $val->__toArray();
}
$as_array['value'] = $values_arr;
} else {
$as_array['value'] = $this->get_value();
}
$as_array = [];
$as_array['value'] = $this->get_value_as_array();
$as_array['value_as_html'] = $this->get_value_as_html();
$as_array['value_as_string'] = $this->get_value_as_string();
$as_array['item'] = $this->get_item()->__toArray();
$as_array['field'] = $this->get_field()->__toArray();
@ -69,7 +154,7 @@ class Item_Metadata_Entity extends Entity {
* @param Item $item
* @return void
*/
function set_item(Item $item) {
function set_item(Item $item = null) {
$this->item = $item;
}
@ -89,7 +174,7 @@ class Item_Metadata_Entity extends Entity {
* @param Field $field
* @return void
*/
function set_field(Field $field) {
function set_field(Field $field = null) {
$this->field = $field;
}
@ -171,9 +256,23 @@ class Item_Metadata_Entity extends Entity {
if (isset($this->value))
return $this->value;
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
return $Tainacan_Item_Metadata->get_value($this);
}
/**
* Check wether the item has a value stored in the database or not
*
* @return bool
*/
function has_value() {
if (isset($this->has_value))
return $this->has_value;
$value = $this->get_value();
$this->has_value = !empty($value);
return $this->has_value;
}
/**
* Return true if field is multiple, else return false
@ -258,12 +357,12 @@ class Item_Metadata_Entity extends Entity {
} else {
if( is_array($value) ){
$this->add_error('not_multiple', $field->get_name() . ' do not accept array as value');
$this->add_error('not_multiple', $field->get_name() . ' do not accept array as value');
return false;
}
if ($this->is_collection_key()) {
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$test = $Tainacan_Items->fetch([
'meta_query' => [

View File

@ -23,6 +23,8 @@ class Item extends Entity {
$order,
$parent,
$decription,
$document_type,
$document,
$collection_id;
/**
@ -219,6 +221,24 @@ class Item extends Entity {
function get_description() {
return $this->get_mapped_property( 'description' );
}
/**
* Return the item document type
*
* @return string
*/
function get_document_type() {
return $this->get_mapped_property( 'document_type' );
}
/**
* Return the item document
*
* @return string
*/
function get_document() {
return $this->get_mapped_property( 'document' );
}
/**
*
@ -272,6 +292,28 @@ class Item extends Entity {
$this->set_mapped_property( 'parent', $value );
}
/**
* Define the document type
*
* @param [string] $value
*
* @return void
*/
function set_document_type( $value ) {
$this->set_mapped_property( 'document_type', $value );
}
/**
* Define the document
*
* @param [string] $value
*
* @return void
*/
function set_document( $value ) {
$this->set_mapped_property( 'document', $value );
}
/**
* Define the description
*
@ -293,7 +335,7 @@ class Item extends Entity {
* @return array Array of ItemMetadata objects
*/
function get_fields() {
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
return $Tainacan_Item_Metadata->fetch( $this, 'OBJECT' );
@ -324,32 +366,29 @@ class Item extends Entity {
return true;
}
if ( parent::validate() ) {
$arrayItemMetadata = $this->get_fields();
if ( $arrayItemMetadata ) {
foreach ( $arrayItemMetadata as $itemMetadata ) {
$is_valid = true;
// avoid core fields to re-validate
$pos = strpos( $itemMetadata->get_field()->get_field_type(), 'Core' );
if ( $pos !== false ) {
continue;
}
// skip validation for Compound Fields
if ( $itemMetadata->get_field()->get_field_type() == 'Tainacan\Field_Types\Compound' ) {
continue;
}
if ( parent::validate() === false ) {
$is_valid = false;
}
if ( ! $itemMetadata->validate() ) {
$errors = $itemMetadata->get_errors();
$this->add_error( $itemMetadata->get_field()->get_name(), $errors );
$arrayItemMetadata = $this->get_fields();
if ( $arrayItemMetadata ) {
foreach ( $arrayItemMetadata as $itemMetadata ) {
// skip validation for Compound Fields
if ( $itemMetadata->get_field()->get_field_type() == 'Tainacan\Field_Types\Compound' ) {
continue;
}
return false;
}
if ( ! $itemMetadata->validate() ) {
$errors = $itemMetadata->get_errors();
$this->add_error( $itemMetadata->get_field()->get_id(), $errors );
$is_valid = false;
}
}
return true;
return $is_valid;
}
return false;
@ -370,4 +409,89 @@ class Item extends Entity {
return parent::validate();
}
public function __toHtml() {
$return = '';
$id = $this->get_id();
if ( $id ) {
$link = get_permalink( (int) $id );
if (is_string($link)) {
$return = "<a data-linkto='item' data-id='$id' href='$link'>";
$return.= $this->get_title();
$return .= "</a>";
}
}
return $return;
}
/**
* Return the item metadata as a HTML string to be used as output.
*
* Each metadata is a label with the field name and the value.
*
* If an ID, a slug or a Tainacan\Entities\Field object is passed, it returns only one metadata, otherwise
* it returns all metadata
*
* @param int|string|Tainacan\Entities\Field $field Field object, ID or slug to retrieve only one field. empty returns all fields
* @param bool $hide_empty Wether to hide or not fields the item has no value to
* @return string The HTML output
*/
public function get_metadata_as_html($field = null, $hide_empty = true) {
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$return = '';
if (!is_null($field)) {
$field_object = null;
if ( $field instanceof \Tainacan\Entities\Field ) {
$field_object = $field;
} elseif ( is_int($field) ) {
$field_object = $Tainacan_Fields->fetch($field);
} elseif ( is_string($field) ) {
$query = $Tainacan_Fields->fetch(['slug' => $field], 'OBJECT');
if ( is_array($query) && sizeof($query) == 1 && isset($field[0])) {
$field_object = $field[0];
}
}
if ( $field_object instanceof \Tainacan\Entities\Field ) {
$item_meta = new \Tainacan\Entities\Item_Metadata_Entity($this, $field_object);
if ($item_meta->has_value() || !$hide_empty) {
$return .= '<h3>' . $field_object->get_name() . '</h3>';
$return .= $item_meta->get_value_as_html();
}
}
return $return;
}
$fields = $this->get_fields();
foreach ( $fields as $item_meta ) {
if ($item_meta->has_value() || !$hide_empty) {
$return .= '<h3>' . $item_meta->get_field()->get_name() . '</h3>';
$return .= $item_meta->get_value_as_html();
}
}
return $return;
}
}

View File

@ -264,7 +264,7 @@ class Log extends Entity {
throw new \Exception( 'msn or new_value is need to log' );
}
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
if ( $log->validate() ) {
return $Tainacan_Logs->insert( $log );
@ -289,12 +289,13 @@ class Log extends Entity {
* {@inheritDoc}
* @see \Tainacan\Entities\Entity::diff()
*/
public function diff($which = 0)
{
public function diff($which = 0) {
$log = $this;
if($which != 0) {
$log = new self($which);
}
$value = $log->get_value();
$old = $log->get_old_value();
return $value->diff($old);

View File

@ -172,4 +172,79 @@ class Term extends Entity {
function set_taxonomy($value) {
$this->set_mapped_property('taxonomy', $value);
}
/**
*
* {@inheritDoc}
* @see \Tainacan\Entities\Entity::validate()
*/
function validate() {
if (!parent::validate())
return false;
$parent = $this->get_parent();
$name = $this->get_name();
$taxonomy = $this->get_taxonomy();
/**
* Code from WordPress Core, taxonomy.php#2070
*/
/*
* Prevent the creation of terms with duplicate names at the same level of a taxonomy hierarchy,
* unless a unique slug has been explicitly provided.
*/
$name_matches = get_terms( $taxonomy, array(
'name' => $name,
'hide_empty' => false,
'parent' => $parent,
) );
/*
* The `name` match in `get_terms()` doesn't differentiate accented characters,
* so we do a stricter comparison here.
*/
$name_match = null;
if ( $name_matches ) {
foreach ( $name_matches as $_match ) {
if ( is_object($_match) && isset($_match) && strtolower( $name ) === strtolower( $_match->name ) ) {
$name_match = $_match;
break;
}
}
}
if ($name_match) {
$this->add_error( 'repeated', __('You can not have two terms with the same name at the same level', 'tainacan') );
return false;
}
return true;
}
public function __toHtml() {
$return = '';
$id = $this->get_id();
if ( $id ) {
$link = get_term_link( (int) $id );
if (is_string($link)) {
$return = "<a data-linkto='term' data-id='$id' href='$link'>";
$return.= $this->get_name();
$return .= "</a>";
}
}
return $return;
}
}

View File

@ -69,7 +69,7 @@ class Category extends Field_Type {
if (empty($this->get_option('taxonomy_id')))
return ['taxonomy_id' => __('Please select a category', 'tainacan')];
$Tainacan_Fields = Fields::getInstance();
$Tainacan_Fields = Fields::get_instance();
$category_fields = $Tainacan_Fields->fetch([
'collection_id' => $field->get_collection_id(),
@ -120,8 +120,8 @@ class Category extends Field_Type {
$terms = array($terms);
foreach ($terms as $term) {
if (is_object($term) && $term instanceof \WP_Term) {
$term = $term->term_id;
if (is_object($term) && $term instanceof \Tainacan\Entities\Term) {
$term = $term->get_id();
}
if (!term_exists($term)) {
@ -136,4 +136,45 @@ class Category extends Field_Type {
}
/**
* Return the value of an Item_Metadata_Entity using a field of this field type as an html string
* @param Item_Metadata_Entity $item_metadata
* @return string The HTML representation of the value, containing one or multiple terms, separated by comma, linked to term page
*/
public function get_value_as_html(Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
$return = '';
if ( $item_metadata->is_multiple() ) {
$count = 1;
$total = sizeof($value);
foreach ( $value as $term ) {
if ( $term instanceof \Tainacan\Entities\Term ) {
$return .= $term->__toHtml();
}
$count ++;
if ( $count <= $total ) {
$return .= ', ';
}
}
} else {
if ( $value instanceof \Tainacan\Entities\Term ) {
$return .= $value->__toHtml();
}
}
return $return;
}
}

View File

@ -39,18 +39,51 @@ class Compound extends Field_Type {
}
public function validate_options( Field $field ) {
// TODO: You cant have a multiple field inside a compound field (except category)
//
// TODO: You cant have a Category field inside a multiple compound field
/**
* Return the value of an Item_Metadata_Entity using a field of this field type as an html string
* @param Item_Metadata_Entity $item_metadata
* @return string The HTML representation of the value, each HTML representation of the value of each field composing this metadata
*/
public function get_value_as_html(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
$return = '';
if ( $item_metadata->is_multiple() ) {
foreach ( $value as $compound_element ) {
foreach ( $compound_element as $meta ) {
if ( $meta instanceof Item_Metadata_Entity ) {
$return .= '<h4>' . $meta->get_field()->get_name() . "</h4>\n";
$return .= '<p>' . $meta->__value_to_html() . '</p>';
}
}
$return .= "<hr />\n\n";
}
} else {
foreach ( $value as $meta ) {
if ( $meta instanceof Item_Metadata_Entity ) {
$return .= '<h4>' . $meta->get_field()->get_name() . "</h4>\n";
$return .= '<p>' . $meta->__value_to_html() . '</p>';
}
}
}
return $return;
return true;
}
}

View File

@ -3,6 +3,7 @@
:id="id"
v-model="dateValue"
@blur="onBlur"
:readonly="false"
@input="onInput($event)"/>
</template>

View File

@ -66,4 +66,63 @@ class Relationship extends Field_Type {
}
return true;
}
/**
* Return the value of an Item_Metadata_Entity using a field of this field type as an html string
* @param Item_Metadata_Entity $item_metadata
* @return string The HTML representation of the value, containing one or multiple items names, linked to the item page
*/
public function get_value_as_html(\Tainacan\Entities\Item_Metadata_Entity $item_metadata) {
$value = $item_metadata->get_value();
$return = '';
if ( $item_metadata->is_multiple() ) {
$count = 1;
$total = sizeof($value);
foreach ( $value as $item_id ) {
try {
$item = new \Tainacan\Entities\Item($item_id);
if ( $item instanceof \Tainacan\Entities\Item ) {
$return .= $item->__toHtml();
}
$count ++;
if ( $count <= $total ) {
$return .= ', ';
}
} catch (Exception $e) {
// item not found
}
}
} else {
try {
$item = new \Tainacan\Entities\Item($value);
if ( $item instanceof \Tainacan\Entities\Item ) {
$return .= $item->__toHtml();
}
} catch (Exception $e) {
// item not found
}
}
return $return;
}
}

View File

@ -71,12 +71,17 @@
return this.inputs;
},
getErrorMessage() {
let msg = '';
let errors = eventBus.getErrors(this.field.field.id);
if ( errors) {
this.setFieldTypeMessage('is-danger');
for (let index in errors) {
msg += errors[index] + '\n';
for (let error of errors) {
for (let index of Object.keys(error)) {
this.$console.log(index);
msg += error[index] + '\n';
}
}
} else {
this.setFieldTypeMessage('');

View File

@ -33,7 +33,7 @@
size="is-small"
closable
@close="clearSearch()">
{{ results }}
{{ label }}
</b-tag>
</div>
</div>
@ -71,6 +71,7 @@
type: '',
collection: '',
field: '',
label: ''
}
},
mixins: [filter_type_mixin],
@ -79,6 +80,7 @@
if(!option)
return;
this.results = option.value;
this.label = option.label;
this.onSelect()
},
onSelect(){
@ -95,7 +97,7 @@
if ( this.type === 'Tainacan\\Field_Types\\Relationship' ) {
let collectionTarget = ( this.field_object && this.field_object.field_type_options.collection_id ) ?
this.field_object.field_type_options.collection_id : this.collection_id;
promise = this.getValuesRelationship( collectionTarget, query );
promise = this.getValuesRelationship( collectionTarget );
} else {
promise = this.getValuesPlainText( this.field, query );
@ -129,6 +131,7 @@
// instance.selected.push({ label: item.title, value: item.id, img: '' });
this.$console.log(item.title);
instance.results = item.title;
instance.label = item.title;
}
})
.catch(error => {
@ -143,6 +146,7 @@
},
clearSearch(){
this.results = '';
this.label = '';
this.selected = '';
this.$emit('input', {
filter: 'autocomplete',

View File

@ -7,7 +7,6 @@
v-model="selected"
:data="options"
autocomplete
:loading="loading"
field="label"
@typing="search" />
</div>
@ -83,11 +82,10 @@
});
},
getValuesCategory( taxonomy, query ){
this.$console.log( query );
return axios.get('/taxonomy/' + taxonomy + '/terms?hideempty=0' ).then( res => {
for (let item of res.data) {
if( item.name.toLowerCase().indexOf( query.toLowerCase() ) >= 0 )
this.options.push(item);
for (let term of res.data) {
if( term.name.toLowerCase().indexOf( query.toLowerCase() ) >= 0 )
this.options.push({label: term.name, value: term.id});
}
})
.catch(error => {

View File

@ -57,10 +57,9 @@
let promise = null;
this.isLoading = true;
if ( this.type === 'Tainacan\\Field_types\\Relationship' ) {
let collectionTarget = ( this.filter && this.filter.field.field_type_options.collection_id ) ?
this.filter.field.field_type_options.collection_id : this.collection_id;
if ( this.type === 'Tainacan\\Field_Types\\Relationship' ) {
let collectionTarget = ( this.field_object && this.field_object.field_type_options.collection_id ) ?
this.field_object.field_type_options.collection_id : this.collection_id;
promise = this.getValuesRelationship( collectionTarget );
} else {

View File

@ -30,7 +30,13 @@ export const filter_type_mixin = {
});
},
getValuesRelationship(collectionTarget, search) {
return axios.get('/collection/' + collectionTarget + '/items?search=' + search)
let url = '/collection/' + collectionTarget + '/items';
if( search ){
url += "?search=" + search;
}
return axios.get( url )
.then(res => {
if (res.data.length > 0) {
for (let item of res.data) {

View File

@ -56,10 +56,9 @@
this.isLoading = true;
let instance = this;
if ( this.type === 'Tainacan\\Field_types\\Relationship' ) {
let collectionTarget = ( this.filter && this.filter.field.field_type_options.collection_id ) ?
this.filter.field.field_type_options.collection_id : this.collection_id;
if ( this.type === 'Tainacan\\Field_Types\\Relationship' ) {
let collectionTarget = ( this.field_object && this.field_object.field_type_options.collection_id ) ?
this.field_object.field_type_options.collection_id : this.collection_id;
promise = this.getValuesRelationship( collectionTarget );
} else {

View File

@ -19,7 +19,7 @@
import { mapActions, mapGetters } from 'vuex';
export default {
name: 'TainacanFiltersList',
name: 'TainacanFilterItem',
props: {
filter: Object,
query: Object

View File

@ -14,7 +14,7 @@ class Collections extends Repository {
private static $instance = null;
public static function getInstance() {
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
@ -221,7 +221,7 @@ class Collections extends Repository {
* @see \Tainacan\Repositories\Repository::insert()
*/
public function insert( $collection ) {
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$this->pre_update_moderators( $collection );
$new_collection = parent::insert( $collection );

View File

@ -22,7 +22,7 @@ class Fields extends Repository {
private static $instance = null;
public static function getInstance()
public static function get_instance()
{
if(!isset(self::$instance))
{
@ -128,15 +128,6 @@ class Fields extends Repository {
'validation' => v::numeric()->positive(),
'default' => 1
],
'privacy' => [
'map' => 'meta',
'title' => __('Privacy', 'tainacan'),
'type' => 'string',
'description'=> __('The field should be omitted in item view', 'tainacan'),
'on_error' => __('Privacy is invalid', 'tainacan'),
'validation' => v::stringType()->in(['yes', 'no']), // yes or no. It cant be multiple if its collection_key
'default' => 'no'
],
'mask' => [
'map' => 'meta',
'title' => __('Mask', 'tainacan'),
@ -167,31 +158,22 @@ class Fields extends Repository {
//'validation' => ''
],
'accept_suggestion' => [
'map' => 'meta',
'title' => __('Field Value Accepts Suggestions', 'tainacan'),
'type' => 'bool',
'description'=> __('Allow the community suggest a different values for that field', 'tainacan'),
'default' => false,
'validation' => v::boolType()
],
'can_delete' => [
'map' => 'meta',
'title' => __('Can delete', 'tainacan'),
'type' => 'string',
'description'=> __('The field can be deleted', 'tainacan'),
'on_error' => __('Can delete is invalid', 'tainacan'),
'validation' => v::stringType()->in(['yes', 'no']), // yes or no. It cant be multiple if its collection_key
'default' => 'yes'
'map' => 'meta',
'title' => __('Field Value Accepts Suggestions', 'tainacan'),
'type' => 'bool',
'description'=> __('Allow the community suggest a different values for that field', 'tainacan'),
'default' => false,
'validation' => v::boolType()
],
'exposer_mapping' => [
'map' => 'meta',
'title' => __('exposer_mapping', 'tainacan'),
'type' => 'array',
'description'=> __('The field mapping options', 'tainacan'),
'on_error' => __('Invalid Field Mapping', 'tainacan'),
'validation' => v::arrayType(),
'default' => []
],
'exposer_mapping' => [
'map' => 'meta',
'title' => __('exposer_mapping', 'tainacan'),
'type' => 'array',
'description'=> __('The field mapping options', 'tainacan'),
'on_error' => __('Invalid Field Mapping', 'tainacan'),
'validation' => v::arrayType(),
'default' => []
],
]);
}
@ -316,7 +298,6 @@ class Fields extends Repository {
$args = array_merge([
'posts_per_page' => -1,
'post_status' => 'publish'
], $args);
$args = $this->parse_fetch_args($args);
@ -447,7 +428,7 @@ class Fields extends Repository {
* @see \Tainacan\Repositories\Repository::insert()
*/
public function insert($field){
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$this->pre_update_category_field($field);
$new_field = parent::insert($field);
@ -671,7 +652,7 @@ class Fields extends Repository {
// handle core titles
if( strpos( $field->get_field_type(), 'Core') !== false ){
$collection = new Entities\Collection( $collection_id );
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$items = $Tainacan_Items->fetch( [], $collection, 'OBJECT');
$return = [];

View File

@ -12,7 +12,7 @@ class Filters extends Repository {
private static $instance = null;
public static function getInstance()
public static function get_instance()
{
if(!isset(self::$instance))
{

View File

@ -16,7 +16,7 @@ class Item_Metadata extends Repository {
private static $instance = null;
public static function getInstance()
public static function get_instance()
{
if(!isset(self::$instance))
{
@ -28,8 +28,21 @@ class Item_Metadata extends Repository {
public function insert($item_metadata) {
$unique = !$item_metadata->is_multiple();
if ( ! $item_metadata->get_validated() ) {
throw new \Exception( 'Entities must be validated before you can save them' );
// TODO: Throw Warning saying you must validate object before insert()
}
$old = $item_metadata;
$is_update = false;
// TODO get props obj before update
if( $item_metadata->get_id() ) {
$is_update = true;
$old = $item_metadata->get_repository()->fetch( $item_metadata->get_id() );
}
$unique = !$item_metadata->is_multiple();
$field_type = $item_metadata->get_field()->get_field_type_object();
if ($field_type->get_core()) {
$this->save_core_field_value($item_metadata);
@ -52,22 +65,22 @@ class Item_Metadata extends Repository {
* and not update an existing. This is the case of a multiple compound field.
*/
if ( $item_metadata->get_field()->get_parent() > 0 && is_null($item_metadata->get_meta_id()) ) {
$added_meta_id = add_post_meta($item_metadata->item->get_id(), $item_metadata->field->get_id(), wp_slash( $item_metadata->get_value() ) );
$added_meta_id = add_post_meta($item_metadata->get_item()->get_id(), $item_metadata->get_field()->get_id(), wp_slash( $item_metadata->get_value() ) );
$added_compound = $this->add_compound_value($item_metadata, $added_meta_id);
} else {
update_post_meta($item_metadata->item->get_id(), $item_metadata->field->get_id(), wp_slash( $item_metadata->get_value() ) );
update_post_meta($item_metadata->get_item()->get_id(), $item_metadata->get_field()->get_id(), wp_slash( $item_metadata->get_value() ) );
}
}
} else {
delete_post_meta($item_metadata->item->get_id(), $item_metadata->field->get_id());
delete_post_meta($item_metadata->get_item()->get_id(), $item_metadata->get_field()->get_id());
if (is_array($item_metadata->get_value())){
$values = $item_metadata->get_value();
foreach ($values as $value){
add_post_meta($item_metadata->item->get_id(), $item_metadata->field->get_id(), wp_slash( $value ));
add_post_meta($item_metadata->get_item()->get_id(), $item_metadata->get_field()->get_id(), wp_slash( $value ));
}
}
}
@ -75,7 +88,7 @@ class Item_Metadata extends Repository {
do_action('tainacan-insert', $item_metadata);
do_action('tainacan-insert', $item_metadata, $old, $is_update);
do_action('tainacan-insert-Item_Metadata_Entity', $item_metadata);
$new_entity = new Entities\Item_Metadata_Entity($item_metadata->get_item(), $item_metadata->get_field());
@ -107,7 +120,7 @@ class Item_Metadata extends Repository {
$value = $item_metadata->get_value();
$item->$set_method( is_array( $value ) ? $value[0] : $value );
if ($item->validate_core_fields()) {
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$Tainacan_Items->insert($item);
} else {
throw new \Exception('Item metadata should be validated beforehand');
@ -165,7 +178,7 @@ class Item_Metadata extends Repository {
*/
public function fetch($object, $output = null ){
if($object instanceof Entities\Item){
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$collection = $object->get_collection();
@ -222,8 +235,12 @@ class Item_Metadata extends Repository {
$terms = wp_get_object_terms($item_metadata->get_item()->get_id(), $taxonomy_slug );
if ($unique)
if ($unique) {
$terms = reset($terms);
if (false !== $terms)
$terms = new Entities\Term($terms);
}
if(is_array($terms)){
$terms_array = [];
@ -240,7 +257,7 @@ class Item_Metadata extends Repository {
global $wpdb;
$rows = $wpdb->get_results(
$wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $item_metadata->get_item()->get_id(), $item_metadata->field->get_id()),
$wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $item_metadata->get_item()->get_id(), $item_metadata->get_field()->get_id()),
ARRAY_A );
$return_value = [];
@ -268,7 +285,7 @@ class Item_Metadata extends Repository {
return $value->meta_value;
}
} else {
return get_post_meta($item_metadata->item->get_id(), $item_metadata->field->get_id(), $unique);
return get_post_meta($item_metadata->get_item()->get_id(), $item_metadata->get_field()->get_id(), $unique);
}
}

View File

@ -12,7 +12,7 @@ class Items extends Repository {
private static $instance = null;
public static function getInstance()
public static function get_instance()
{
if(!isset(self::$instance))
{
@ -91,8 +91,23 @@ class Items extends Repository {
'type' => 'array',
'description' => __( 'The item term IDs', 'tainacan' ),
],
//'collection' => 'relation...',
// field .. field...
'document_type' => [
'map' => 'meta',
'title' => __('Document Type', 'tainacan'),
'type' => 'string',
'description'=> __('The document type, can be a local attachment, an external URL or a text', 'tainacan'),
'on_error' => __('Invalid document type', 'tainacan'),
'validation' => v::stringType()->in(['attachment', 'url', 'text']),
'default' => 'attachment'
],
'document' => [
'map' => 'meta',
'title' => __('Document', 'tainacan'),
'type' => 'string',
'description'=> __('The document itself. An ID in case of attachment, an URL in case of url or a text in the case of text', 'tainacan'),
'on_error' => __('Invalid document', 'tainacan'),
'default' => ''
],
] );
}
@ -127,11 +142,11 @@ class Items extends Repository {
*/
public function register_post_type() {
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$collections = $Tainacan_Collections->fetch( [], 'OBJECT' );
$taxonomies = $Tainacan_Taxonomies->fetch( [], 'OBJECT' );
$taxonomies = $Tainacan_Taxonomies->fetch( ['status' => ['auto-draft', 'draft', 'publish', 'private']], 'OBJECT' );
if ( ! is_array( $collections ) ) {
return;
@ -152,6 +167,14 @@ class Items extends Repository {
public function insert( $item ) {
$old = $item;
$is_update = false;
// TODO get props obj before update
if( $item->get_id() ) {
$is_update = true;
$old = $item->get_repository()->fetch( $item->get_id() );
}
$map = $this->get_map();
// get collection to determine post type
@ -198,7 +221,7 @@ class Items extends Repository {
set_post_thumbnail( $item->WP_Post, $item->get_featured_img_id( $item->WP_Post->ID ) );
}
do_action( 'tainacan-insert', $item );
do_action( 'tainacan-insert', $item, $old, $is_update );
do_action( 'tainacan-insert-Item', $item );
// return a brand new object
@ -224,7 +247,7 @@ class Items extends Repository {
*/
public function fetch( $args = [], $collections = [], $output = null ) {
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
if ( is_numeric( $args ) ) {
$existing_post = get_post( $args );
@ -348,11 +371,15 @@ class Items extends Repository {
if(is_array( $post_title_in ) && isset( $post_title_in['value']) ){
$quotes = [];
foreach ($post_title_in['value'] as $title) {
$quotes[] = "'" . esc_sql( $wpdb->esc_like( $title ) ). "'";
$quotes[] = " $wpdb->posts.post_title LIKE '%" . esc_sql( $wpdb->esc_like( $title ) ). "%'";
}
}
$where .= ' '.$post_title_in['relation'].' ' . $wpdb->posts . '.post_title IN ( ' .implode(',', $quotes ) . ')';
// retrieve only posts for the specified collection and status
$type = " $wpdb->posts.post_type = '" . $wp_query->get( 'post_type' )[0]."' ";
$status = " ( $wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'private') ";
$where .= ' '.$post_title_in['relation'] . '( ( ' .implode(' OR ', $quotes ) . ' ) AND ' .
$status . ' AND ' . $type . ' )';
}
return $where;
}
@ -370,11 +397,15 @@ class Items extends Repository {
if(is_array( $post_content_in ) && isset( $post_content_in['value']) ){
$quotes = [];
foreach ($post_content_in['value'] as $title) {
$quotes[] = "'" . esc_sql( $wpdb->esc_like( $title ) ). "'";
$quotes[] = " $wpdb->posts.post_content LIKE '%" .esc_sql( $wpdb->esc_like( $title ) ). "%'";
}
}
$where .= ' '.$post_content_in['relation'].' ' . $wpdb->posts . '.post_content IN ( ' .implode(',', $quotes ) . ')';
// retrieve only posts for the specified collection and status
$type = " $wpdb->posts.post_type = '" . $wp_query->get( 'post_type' )[0]."' ";
$status = " ( $wpdb->posts.post_status = 'publish' OR $wpdb->posts.post_status = 'private') ";
$where .= ' '.$post_content_in['relation'] . '( ( ' .implode(' OR ', $quotes ) . ' ) AND ' .
$status . ' AND ' . $type . ' )';
}
return $where;
}

View File

@ -17,7 +17,7 @@ class Logs extends Repository {
public $entities_type = '\Tainacan\Entities\Log';
private static $instance = null;
public static function getInstance() {
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
@ -28,7 +28,7 @@ class Logs extends Repository {
protected function __construct() {
parent::__construct();
add_action( 'tainacan-insert', array( $this, 'log_inserts' ), 10, 2 );
add_action( 'tainacan-insert', array( $this, 'log_inserts' ), 10, 3 );
}
public function get_map() {
@ -76,9 +76,9 @@ class Logs extends Repository {
'description' => __( 'The log slug' ),
'validation' => ''
],
'itens_per_page' => [
'items_per_page' => [
'map' => 'meta',
'title' => __( 'Itens per page', 'tainacan' ),
'title' => __( 'Items per page', 'tainacan' ),
'type' => 'integer',
'description' => __( 'The quantity of items that should be load' ),
'validation' => ''
@ -211,6 +211,8 @@ class Logs extends Repository {
$args = [
'post_type' => Entities\Log::get_post_type(),
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC'
];
$logs = $this->fetch( $args, 'OBJECT' );
@ -222,11 +224,11 @@ class Logs extends Repository {
* Insert a log when a new entity is inserted
*
* @param Entity $new_value
* @param Entity $value
* @param Entity $old_value
*
* @return Entities\Log new created log
*/
public function log_inserts( $new_value, $value = null ) {
public function log_inserts( $new_value, $old_value = null, $is_update = null ) {
$msn = "";
$description = "";
@ -242,15 +244,34 @@ class Logs extends Repository {
$name = method_exists($new_value, 'get_name') ? $new_value->get_name() :
(method_exists($new_value, 'get_title') ? $new_value->get_title() : $new_value->get_field()->get_name());
$msn = sprintf( esc_html__( 'A %s has been created/updated.', 'tainacan' ), $class_name);
$description = sprintf( esc_html__("The %s %s has been created/updated.", 'tainacan' ), $name, strtolower($class_name));
$articleA = 'A';
$articleAn = 'An';
$vowels = 'aeiou';
if($is_update){
if(substr_count($vowels, strtolower(substr($class_name, 0, 1))) > 0){
$msn = sprintf( __( '%s %s has been updated.', 'tainacan' ), $articleAn, $class_name);
$description = sprintf( __("The \"%s\" %s has been updated.", 'tainacan' ), $name, strtolower($class_name));
} else {
$msn = sprintf( __( '%s %s has been updated.', 'tainacan' ), $articleA, $class_name);
$description = sprintf( __("The \"%s\" %s has been updated.", 'tainacan' ), $name, strtolower($class_name));
}
} else {
if(substr_count($vowels, strtolower(substr($class_name, 0, 1))) > 0){
$msn = sprintf( __( '%s %s has been created.', 'tainacan' ), $articleAn, $class_name);
$description = sprintf( __("The \"%s\" %s has been created.", 'tainacan' ), $name, strtolower($class_name));
} else {
$msn = sprintf( __( '%s %s has been created.', 'tainacan' ), $articleA, $class_name);
$description = sprintf( __("The \"%s\" %s has been created.", 'tainacan' ), $name, strtolower($class_name));
}
}
}
$msn = apply_filters( 'tainacan-insert-log-message-title', $msn, $type, $new_value );
$description = apply_filters('tainacan-insert-log-description', $description, $type, $new_value);
return Entities\Log::create( $msn, $description, $new_value, $value );
return Entities\Log::create( $msn, $description, $new_value, $old_value );
}
/**
@ -265,7 +286,9 @@ class Logs extends Repository {
if ( $log->get_status() == 'pending' ) {
/** @var Entity $value * */
$value = $log->get_value();
//$value->set_status('publish'); // TODO check if publish the entity on approve
$repository = self::get_repository( $value );
return $repository->insert( $value );

View File

@ -77,7 +77,12 @@ abstract class Repository {
}
$old = $obj;
if( $obj->get_id() ) $old = $obj->get_repository()->fetch($obj->get_id()); //TODO get props obj before update
$is_update = false;
// TODO get props obj before update
if( $obj->get_id() ) {
$is_update = true;
$old = $obj->get_repository()->fetch( $obj->get_id() );
}
$map = $this->get_map();
@ -113,7 +118,7 @@ abstract class Repository {
set_post_thumbnail( $obj->WP_Post, $obj->get_featured_img_id( $obj->WP_Post->ID ) );
}
do_action( 'tainacan-insert', $obj, $old );
do_action( 'tainacan-insert', $obj, $old, $is_update );
do_action( 'tainacan-insert-' . $obj->get_post_type(), $obj );
// return a brand new object
@ -337,7 +342,7 @@ abstract class Repository {
* @return array[]
*/
public static function get_collections_db_identifier() {
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$collections = $Tainacan_Collections->fetch( [], 'OBJECT' );
$cpts = [];
foreach ( $collections as $col ) {
@ -361,6 +366,9 @@ abstract class Repository {
return $post;
}
if (!$post instanceof \WP_Post)
return false;
$post_type = $post->post_type;
return self::get_entity_by_post_type( $post_type, $post );
@ -385,19 +393,19 @@ abstract class Repository {
} else {
throw new \Exception( 'Collection object not found for this post' );
}
} elseif ($post_type === \Tainacan\Repositories\Item_Metadata::get_instance()->entities_type::get_post_type()){
return new Entities\Item_Metadata_Entity(null, null);
} else {
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance();
$tnc_globals = [
$Tainacan_Collections,
$Tainacan_Fields,
$Tainacan_Item_Metadata,
$Tainacan_Filters,
$Tainacan_Taxonomies,
$Tainacan_Terms,
@ -427,17 +435,17 @@ abstract class Repository {
// its is a collection Item?
if ( $prefix == Entities\Collection::$db_identifier_prefix ) {
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
return $Tainacan_Items;
} else {
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
$tnc_globals = [
$Tainacan_Collections,
@ -606,8 +614,10 @@ abstract class Repository {
*/
public function diff( $old = 0, $new ) {
$old_entity = null;
if ( $old === 0 ) { // self diff or other entity?
$id = $new->get_id();
if ( ! empty( $id ) ) { // there is a repository entity?
$old_entity = $this->get_entity_by_post( $new->WP_Post->ID );
} else {
@ -617,6 +627,7 @@ abstract class Repository {
} else { // get entity from repository
$old_entity = $this->get_entity_by_post( $old );
}
$new_entity = $this->get_entity_by_post( $new );
$map = $this->get_map();
@ -625,23 +636,37 @@ abstract class Repository {
foreach ( $map as $prop => $mapped ) {
if ( $old_entity->get_mapped_property( $prop ) != $new_entity->get_mapped_property( $prop ) ) {
if ( $mapped['map'] == 'meta_multi' ) {
$meta_diff = array_diff( $new_entity->get_mapped_property( $prop ), $old_entity->get_mapped_property( $prop ) );
if ( ! empty( $meta_diff ) ) {
// Array of diffs with index of diff in new array
$array_diff_with_index = array_diff_assoc($new_entity->get_mapped_property( $prop ), $old_entity->get_mapped_property( $prop ));
if ( ! empty( $array_diff_with_index ) ) {
$diff[ $prop ] = [
'new' => $new_entity->get_mapped_property( $prop ),
'old' => $old_entity->get_mapped_property( $prop ),
'diff' => $meta_diff //TODO better expose difference
'diff_with_index' => $array_diff_with_index,
];
}
} else {
$new_as_array = explode(' ', $new_entity->get_mapped_property( $prop ));
$old_as_array = explode(' ', $old_entity->get_mapped_property( $prop ));
// Array of diffs with index of diff in new array
$array_diff_with_index = array_diff_assoc($new_as_array, $old_as_array);
$diff[ $prop ] = [
'new' => $new_entity->get_mapped_property( $prop ),
'old' => $old_entity->get_mapped_property( $prop )
'new' => $new_as_array,
'old' => $old_entity->get_mapped_property( $prop ),
'diff_with_index' => $array_diff_with_index,
];
}
}
}
$diff = apply_filters( 'tainacan-entity-diff', $diff, $new, $old );
return $diff;

View File

@ -15,7 +15,7 @@ class Taxonomies extends Repository {
private static $instance = null;
public static function getInstance()
public static function get_instance()
{
if(!isset(self::$instance))
{
@ -139,31 +139,6 @@ class Taxonomies extends Repository {
return $new_taxonomy;
}
public function tainacan_taxonomy( $taxonomy_name ){
$labels = array(
'name' => __( 'Taxonomies', 'textdomain' ),
'singular_name' => __( 'Taxonomy','textdomain' ),
'search_items' => __( 'Search taxonomies', 'textdomain' ),
'all_items' => __( 'All taxonomies', 'textdomain' ),
'parent_item' => __( 'Parent taxonomy', 'textdomain' ),
'parent_item_colon' => __( 'Parent taxonomy:', 'textdomain' ),
'edit_item' => __( 'Edit taxonomy', 'textdomain' ),
'update_item' => __( 'Update taxonomy', 'textdomain' ),
'add_new_item' => __( 'Add New taxonomy', 'textdomain' ),
'new_item_name' => __( 'New Genre taxonomy', 'textdomain' ),
'menu_name' => __( 'Genre', 'textdomain' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => tnc_enable_dev_wp_interface(),
'show_admin_column' => tnc_enable_dev_wp_interface(),
);
register_taxonomy( $taxonomy_name, array( ), $args );
}
/**
* fetch taxonomies based on ID or WP_Query args
*

View File

@ -15,7 +15,7 @@ class Terms extends Repository {
private static $instance = null;
public static function getInstance()
public static function get_instance()
{
if(!isset(self::$instance))
{
@ -100,6 +100,15 @@ class Terms extends Repository {
* @return Entities\Entity|Entities\Term
*/
public function insert($term){
$old = $term;
$is_update = false;
// TODO get props obj before update
if( $term->get_id() ) {
$is_update = true;
$old = $term->get_repository()->fetch( $term->get_id() );
}
// First iterate through the native post properties
$map = $this->get_map();
foreach ($map as $prop => $mapped) {
@ -138,7 +147,7 @@ class Terms extends Repository {
}
}
do_action('tainacan-insert', $term);
do_action('tainacan-insert', $term, $old, $is_update);
do_action('tainacan-insert-Term', $term);
return new Entities\Term($term_saved['term_id'], $term->get_taxonomy());
@ -159,7 +168,11 @@ class Terms extends Repository {
*/
public function fetch( $args = [], $taxonomies = []){
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
if (is_numeric($taxonomies)){
$taxonomies = $Tainacan_Taxonomies->fetch( $taxonomies );
}
if ( $taxonomies instanceof Entities\Taxonomy ) {
$cpt = $taxonomies->get_db_identifier();

View File

@ -80,11 +80,11 @@ function tainacan_autoload($class_name){
}
}
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
//register field types
$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Text');
@ -96,7 +96,7 @@ $Tainacan_Fields->register_field_type('Tainacan\Field_Types\Relationship');
$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Category');
$Tainacan_Fields->register_field_type('Tainacan\Field_Types\Compound');
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
//register filter type
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Custom_Interval');
@ -108,13 +108,13 @@ $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\CategoryTaginput'
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\CategoryCheckbox');
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\CategorySelectbox');
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$Tainacan_Terms = \Tainacan\Repositories\Terms::getInstance();
$Tainacan_Terms = \Tainacan\Repositories\Terms::get_instance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
global $Tainacan_Exposers;
$Tainacan_Exposers = new \Tainacan\Exposers\Exposers();

View File

@ -31,7 +31,7 @@ trait Entity_Collection_Relation {
return $this->collection;
if (is_numeric($this->get_collection_id())) {
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$this->collection = $Tainacan_Collections->fetch($this->get_collection_id());
return $this->collection;

View File

@ -16,7 +16,7 @@ trait Entity_Collections_Relation {
return $this->collections;
if (is_array($this->get_collections_ids()) && !empty($this->get_collections_ids())) {
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$this->collections = [];

View File

@ -11,7 +11,7 @@ class DevInterface {
private static $instance = null;
public static function getInstance()
public static function get_instance()
{
if(!isset(self::$instance))
{
@ -29,11 +29,11 @@ class DevInterface {
add_filter('post_type_link', array(&$this, 'permalink_filter'), 10, 3);
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$repositories = [$Tainacan_Collections, $Tainacan_Filters, $Tainacan_Logs, $Tainacan_Fields, $Tainacan_Taxonomies];
@ -54,7 +54,7 @@ class DevInterface {
'components' => $components
];
$tainacan_settings = \Tainacan\Admin::getInstance()->get_admin_js_localization_params();
$tainacan_settings = \Tainacan\Admin::get_instance()->get_admin_js_localization_params();
$settings = array_merge($settings, $tainacan_settings);
@ -114,7 +114,7 @@ class DevInterface {
}
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
foreach ($collections as $col) {
@ -133,23 +133,23 @@ class DevInterface {
}
function properties_metabox_Collections() {
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$this->properties_metabox($Tainacan_Collections);
}
function properties_metabox_Filters() {
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$this->properties_metabox($Tainacan_Filters);
}
function properties_metabox_Logs() {
$Tainacan_Logs = \Tainacan\Repositories\Logs::getInstance();
$Tainacan_Logs = \Tainacan\Repositories\Logs::get_instance();
$this->properties_metabox($Tainacan_Logs);
}
function properties_metabox_Fields() {
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$this->properties_metabox($Tainacan_Fields);
}
function properties_metabox_Taxonomies() {
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::getInstance();
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
$this->properties_metabox($Tainacan_Taxonomies);
}
@ -227,8 +227,8 @@ class DevInterface {
function metadata_metabox() {
global $typenow, $post;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
@ -299,8 +299,8 @@ class DevInterface {
function metadata_components_metabox() {
global $typenow, $post;
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
@ -372,7 +372,7 @@ class DevInterface {
function field_type_dropdown($id,$selected) {
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$class = ( class_exists( $selected ) ) ? new $selected() : '';
@ -399,7 +399,7 @@ class DevInterface {
function filter_type_dropdown($id,$selected) {
$Tainacan_Filters = \Tainacan\Repositories\Filters::getInstance();
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$class = ( class_exists( $selected ) ) ? new $selected() : '';
@ -430,7 +430,7 @@ class DevInterface {
}
function collections_checkbox_list($selected) {
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
$selected = json_decode($selected);
?>
@ -505,10 +505,10 @@ class DevInterface {
// TODO: there should ve a method in the repository to find this out
// or I could try to initialize an entity and find out what type it is
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
$cpts = [];

View File

@ -12,7 +12,7 @@ use Tainacan\Entities;
* @param string $name_field (optional) default 'tnc_prop_collections_id'
*/
public static function collections_dropdown($selected, $name_field = 'tnc_prop_collection_id'){
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
?>
<select name="<?php echo $name_field ?>">
@ -30,7 +30,7 @@ use Tainacan\Entities;
* @param string $name_field (optional) default 'tnc_prop_collections_ids[]'
*/
public static function collections_checkbox_list($selected,$name_field = 'tnc_prop_collections_ids[]') {
$Tainacan_Collections = \Tainacan\Repositories\Collections::getInstance();
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
$collections = $Tainacan_Collections->fetch([], 'OBJECT');
$selected = json_decode($selected);
?>
@ -51,7 +51,7 @@ use Tainacan\Entities;
* @param array $args (optional) filter the field list
*/
public static function metadata_dropdown( $collection , $selected, $name_field = 'tnc_prop_field_id', $args = []){
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$collection = ( is_numeric( $collection ) ) ? new Entities\Collection( $collection ) : $collection;
$field = $Tainacan_Fields->fetch_by_collection( $collection, $args, 'OBJECT');
?>
@ -74,7 +74,7 @@ use Tainacan\Entities;
* @param array $args (optional) filter the field list
*/
public static function metadata_checkbox_list( $collection , $selected,$name_field = 'tnc_prop_tnc_field_ids[]', $args = []) {
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$collection = ( is_numeric( $collection ) ) ? new Entities\Collection( $collection ) : $collection;
$field = $Tainacan_Fields->fetch_by_collection( $collection, $args, 'OBJECT');
$selected = ( is_array( $selected) ) ? $selected : json_decode($selected);

View File

@ -343,9 +343,9 @@ abstract class Importer {
* @return Tainacan\Entities\Item Item inserted
*/
public function insert( $index, $processed_item ){
$Tainacan_Fields = \Tainacan\Repositories\Fields::getInstance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::getInstance();
$Tainacan_Items = \Tainacan\Repositories\Items::getInstance();
$Tainacan_Fields = \Tainacan\Repositories\Fields::get_instance();
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
$isUpdate = ( is_array( $this->processed_items ) && isset( $this->processed_items[ $index ] ) )
? $this->processed_items[ $index ] : 0;
@ -424,15 +424,15 @@ abstract class Importer {
$new_collection = new Entities\Collection();
$new_collection->set_name('New Imported Collection');
$new_collection->set_status('publish');
$new_collection->validade();
$new_collection = \Tainacan\Repositories\Collections::get_instance()->insert($new_collection);
$new_collection->validate();
$new_collection = Tainacan\Repositories\Collections::get_instance()->insert($new_collection);
$this->set_collection($new_collection);
if (!method_exists($this, 'create_fields_and_mapping')) {
throw new Exception('Importers with import_structure_and_mapping true must implement create_fields_and_mapping method');
}
$this->create_fields_and_mapping();
}

View File

@ -11,11 +11,13 @@ namespace Tainacan\Importer;
class Old_Tainacan extends Importer
{
public function __construct() {
public function __construct($import_structure_and_mapping = false) {
parent::__construct();
$this->remove_import_method('file');
$this->add_import_method('url');
$this->import_structure_and_mapping = $import_structure_and_mapping;
}
/**
@ -26,7 +28,6 @@ class Old_Tainacan extends Importer
*/
public function get_fields()
{
// TODO: Implement get_fields() method.
$file = new \SplFileObject( $this->tmp_file, 'r' );
$json = json_decode($file->fread($file->getSize()), true);
@ -65,10 +66,36 @@ class Old_Tainacan extends Importer
return $processedItem;
}
function create_fields_and_mapping() {
$file = new \SplFileObject( $this->tmp_file, 'r' );
$json = json_decode($file->fread($file->getSize()), true);
print ".";
/*$fields_repository = \Tainacan\Repositories\Fields::get_instance();
$newField = new \Tainacan\Entities\Field();
$newField->set_name = 'New Field';
$newField->set_field_type = 'Tainacan\Field_Types\Text';
$newField->set_collection($this->collection);
$newField->validate(); // there is no user input here, so we can be sure it will validate.
$newField = $fields_repository->insert($newField);
$source_fields = $this->get_fields();
$this->set_mapping([
$newField->get_id() => $source_fields[0]
]);*/
}
/**
* Method implemented by the child importer class to return the number of items to be imported
* @return int
*/
* Method implemented by the child importer class to return the number of items to be imported
* @return int
*/
public function get_total_items_from_source()
{
$file = new \SplFileObject( $this->tmp_file, 'r' );

View File

@ -11,6 +11,7 @@ export const eventBus = new Vue({
if( tainacan_plugin.components ){
this.componentsTag = tainacan_plugin.components;
}
this.$on('input', data => this.updateValue(data) );
},
methods : {
registerComponent( name ){
@ -22,6 +23,7 @@ export const eventBus = new Vue({
const components = this.getAllComponents();
for (let eventElement of components){
eventElement.addEventListener('input', (event) => {
if (event.detail && event.detail[0] ){
this.updateValue({
item_id: $(eventElement).attr("item_id"),
@ -37,30 +39,31 @@ export const eventBus = new Vue({
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 });
promisse.then( () => {
let index = this.errors.findIndex( errorItem => errorItem.field_id === data.field_id );
promisse.then( () => {
let index = this.errors.findIndex( errorItem => errorItem.field_id == data.field_id );
if ( index >= 0){
this.errors.splice( index, 1);
}
}, error => {
let index = this.errors.findIndex( errorItem => errorItem.field_id === data.field_id );
let messages = null;
})
.catch((error) => {
let index = this.errors.findIndex( errorItem => errorItem.field_id == data.field_id );
let messages = [];
for (let index in error) {
messages = error[index]
messages.push(error[index]);
}
if ( index >= 0){
Vue.set( this.errors, index, { field_id: data.field_id, errors: messages });
}else{
} else {
this.errors.push( { field_id: data.field_id, errors: messages } );
}
});
}
},
getErrors(field_id){
let error = this.errors.find( errorItem => errorItem.field_id === field_id );
console.log(this.errors);
let error = this.errors.find( errorItem => errorItem.field_id == field_id );
return ( error ) ? error.errors : false
},
setValues(){

View File

@ -24,6 +24,10 @@ export const eventSearchBus = new Vue({
this.$route.query.perpage = 12;
if (this.$route.query.paged == undefined)
this.$route.query.paged = 1;
if (this.$route.query.order == undefined)
this.$route.query.order = 'DESC';
if (this.$route.query.orderby == undefined)
this.$route.query.orderby = 'date';
store.dispatch('search/set_postquery', this.$route.query);
//console.log(this.$route.query);
@ -59,6 +63,14 @@ export const eventSearchBus = new Vue({
store.dispatch('search/setItemsPerPage', itemsPerPage);
this.updateURLQueries();
},
setOrderBy(newOrderBy) {
store.dispatch('search/setOrderBy', newOrderBy);
this.updateURLQueries();
},
setOrder(newOrder) {
store.dispatch('search/setOrder', newOrder);
this.updateURLQueries();
},
updateURLQueries() {
router.push({ query: {} });
router.push({ query: store.getters['search/getPostQuery'] });

View File

@ -53,7 +53,7 @@ export const updateCategory = ({ commit }, category) => {
resolve( category );
})
.catch(error => {
reject( error.response );
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
});
});
};
@ -125,7 +125,7 @@ export const sendTerm = ({commit}, { categoryId, name, description, parent }) =>
resolve( term );
})
.catch(error => {
reject( error );
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
});
});
};
@ -139,7 +139,7 @@ export const deleteTerm = ({ commit }, { categoryId, termId }) => {
resolve( term );
})
.catch(error => {
reject( error )
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
});
});
};
@ -157,8 +157,7 @@ export const updateTerm = ({ commit }, { categoryId, termId, name, description,
resolve( term );
})
.catch(error => {
reject(error)
//reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
});
});
};

View File

@ -0,0 +1,57 @@
import axios from '../../../axios/axios'
export const fetchEvents = ({ commit }, { page, eventsPerPage } ) => {
return new Promise((resolve, reject) => {
axios.tainacan.get(`/logs?paged=${page}&perpage=${eventsPerPage}`)
.then(res => {
let events = res.data;
commit('setEvents', events);
resolve({
events: events,
total: res.headers['x-wp-total']
});
})
.catch(error => reject(error));
});
};
export const fetchEvent = ({ commit }, eventId) => {
return new Promise((resolve, reject) => {
axios.tainacan.get(`/logs/${eventId}?context=edit`)
.then(res => {
let event = res.data;
commit('setEvent', event);
resolve({
event: event
});
})
.catch(error => reject(error));
});
};
export const fetchEventTitle = ({ commit }, eventId) => {
return new Promise((resolve, reject) => {
axios.tainacan.get(`/logs/${eventId}?fetch_only=title`)
.then(res => {
let eventTitle = res.data;
commit('setEventTitle', eventTitle.title);
resolve(eventTitle.title);
})
.catch(error => reject(error));
})
};
export const approve = ({commit}, eventId) => {
};
export const notApprove = ({commit}, eventId) => {
};

View File

@ -6,6 +6,6 @@ export const getEvent = state => {
return state.event;
};
export const getEventName = state => {
return state.eventName;
export const getEventTitle = state => {
return state.eventTitle;
};

View File

@ -5,7 +5,7 @@ import * as mutations from './mutations';
const state = {
events: [],
event: {},
eventName: String,
eventTitle: String,
};
export default {

View File

@ -0,0 +1,11 @@
export const setEvents = (state, events) => {
state.events = events;
};
export const setEvent = (state, event) => {
state.event = event;
};
export const setEventTitle = (state, eventTitle) => {
state.eventTitle = eventTitle;
};

View File

@ -1,29 +0,0 @@
import axios from '../../../axios/axios'
export const fetchEvents = ({ commit }, { page, eventsPerPage } ) => {
return new Promise((resolve, reject) => {
axios.tainacan.get(`/logs?paged=${page}&perpage=${eventsPerPage}`)
.then(res => {
let events = res.data;
commit('setEvents', events);
resolve({
'events': events,
'total': res.headers['x-wp-total']
});
})
.catch(error => {
reject(error);
});
});
};
export const approve = ({commit}, eventId) => {
};
export const notApprove = ({commit}, eventId) => {
};

View File

@ -1,3 +0,0 @@
export const setEvents = (state, events) => {
state.events = events;
};

Some files were not shown because too many files have changed in this diff Show More