Rename category to taxonomy and categories to taxonomies
This commit is contained in:
parent
94dc0ee35d
commit
430b57c135
|
@ -1,4 +1,4 @@
|
|||
describe('Category test', function () {
|
||||
describe('Taxonomy test', function () {
|
||||
beforeEach(() => {
|
||||
cy.loginByUI()
|
||||
})
|
||||
|
@ -8,100 +8,100 @@ describe('Category test', function () {
|
|||
})
|
||||
|
||||
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()
|
||||
it('canceled create taxonomy', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/taxonomies')
|
||||
cy.location('hash').should('eq', '#/taxonomies')
|
||||
//cy.get('#button-taxonomy-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.location('hash').should('eq', '#/taxonomies/new')
|
||||
cy.get('#tainacan-text-name').type('Taxonomy canceled')
|
||||
cy.get('#tainacan-text-description').type('description taxonomy 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('#button-cancel-taxonomy-creation').click()
|
||||
cy.location('hash').should('eq', '#/taxonomies/')
|
||||
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()
|
||||
it('create taxonomy with status publish', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/taxonomies')
|
||||
cy.location('hash').should('eq', '#/taxonomies')
|
||||
//cy.get('#button-taxonomy-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.location('hash').should('eq', '#/taxonomies/new')
|
||||
cy.get('#tainacan-text-name').type('Taxonomy publish')
|
||||
cy.get('#tainacan-text-description').type('description taxonomy 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')
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.location('hash').should('eq', '#/taxonomies/')
|
||||
cy.get('td').should('contain', 'Taxonomy 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()
|
||||
it('create taxonomy with status private', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/taxonomies')
|
||||
cy.location('hash').should('eq', '#/taxonomies')
|
||||
//cy.get('#button-taxonomy-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.location('hash').should('eq', '#/taxonomies/new')
|
||||
cy.get('#tainacan-text-name').type('Taxonomy private')
|
||||
cy.get('#tainacan-text-description').type('description taxonomy 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')
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.location('hash').should('eq', '#/taxonomies/')
|
||||
cy.get('td').should('contain', 'Taxonomy 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()
|
||||
it('create taxonomy with status draft', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/taxonomies')
|
||||
cy.location('hash').should('eq', '#/taxonomies')
|
||||
//cy.get('#button-taxonomy-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.location('hash').should('eq', '#/taxonomies/new')
|
||||
cy.get('#tainacan-text-name').type('Taxonomy draft')
|
||||
cy.get('#tainacan-text-description').type('description taxonomy 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')
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.location('hash').should('eq', '#/taxonomies/')
|
||||
cy.get('td').should('not.contain', 'Taxonomy 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()
|
||||
it('create taxonomy with status draft', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/taxonomies')
|
||||
cy.location('hash').should('eq', '#/taxonomies')
|
||||
//cy.get('#button-taxonomy-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.location('hash').should('eq', '#/taxonomies/new')
|
||||
cy.get('#tainacan-text-name').type('Taxonomy trash')
|
||||
cy.get('#tainacan-text-description').type('description taxonomy 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')
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.location('hash').should('eq', '#/taxonomies/')
|
||||
cy.get('td').should('not.contain', 'Taxonomy 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()
|
||||
it('create taxonomy color', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/taxonomies')
|
||||
cy.location('hash').should('eq', '#/taxonomies')
|
||||
//cy.get('#button-taxonomy-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.location('hash').should('eq', '#/taxonomies/new')
|
||||
cy.get('#tainacan-text-name').type('Taxonomy color')
|
||||
cy.get('#tainacan-text-description').type('description taxonomy 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')
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.location('hash').should('eq', '#/taxonomies/')
|
||||
cy.get('td').should('contain', 'Taxonomy color')
|
||||
})
|
||||
|
||||
it('delete category color', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/categories')
|
||||
cy.location('hash').should('eq', '#/categories')
|
||||
it('delete taxonomy color', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/taxonomies')
|
||||
cy.location('hash').should('eq', '#/taxonomies')
|
||||
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
|
||||
cy.get('.b-table').should('contain', 'Category trash')
|
||||
cy.get('.b-table').should('contain', 'Taxonomy 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')
|
||||
cy.get('.b-table').should('not.contain', 'Taxonomy trash')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
context('Category field test', function(){
|
||||
context('Taxonomy field test', function(){
|
||||
beforeEach(() => {
|
||||
cy.loginByUI()
|
||||
})
|
||||
|
@ -27,40 +27,40 @@ context('Category field test', function(){
|
|||
cy.get('#tainacan-text-name').type('Cat 1')
|
||||
cy.get('#tainacan-text-description').type('description cat 1')
|
||||
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
|
||||
cy.get('#button-submit-category-creation').click()
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.get('.page-container').should('contain', 'Cat 1')
|
||||
cy.get('.button').click()
|
||||
cy.get('#tainacan-text-name').type('Cat 2')
|
||||
cy.get('#tainacan-text-description').type('description cat 2')
|
||||
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
|
||||
cy.get('#button-submit-category-creation').click()
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.get('.page-container').should('contain', 'Cat 2')
|
||||
cy.get('.button').click()
|
||||
cy.get('#tainacan-text-name').type('Cat 3')
|
||||
cy.get('#tainacan-text-description').type('description cat 3')
|
||||
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
|
||||
cy.get('#button-submit-category-creation').click()
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.get('.page-container').should('contain', 'Cat 3')
|
||||
cy.get('.button').click()
|
||||
cy.get('#tainacan-text-name').type('Cat 4')
|
||||
cy.get('#tainacan-text-description').type('description cat 4')
|
||||
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
|
||||
cy.get('#button-submit-category-creation').click()
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.get('.page-container').should('contain', 'Cat 4')
|
||||
cy.get('.button').click()
|
||||
cy.get('#tainacan-text-name').type('Cat 5')
|
||||
cy.get('#tainacan-text-description').type('description cat 5')
|
||||
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
|
||||
cy.get('#button-submit-category-creation').click()
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.get('.page-container').should('contain', 'Cat 5')
|
||||
cy.get('#tainacan-text-name').type('Cat 6')
|
||||
cy.get('#tainacan-text-description').type('description cat 6')
|
||||
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
|
||||
cy.get('#button-submit-category-creation').click()
|
||||
cy.get('#button-submit-taxonomy-creation').click()
|
||||
cy.get('.page-container').should('contain', 'Cat 6')
|
||||
})
|
||||
|
||||
it('canceled create category-type field public', function(){
|
||||
it('canceled create taxonomy-type field public', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
|
||||
cy.location('hash').should('eq', '#/collections')
|
||||
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
|
||||
|
@ -69,14 +69,14 @@ context('Category field test', function(){
|
|||
cy.get('h1').should('contain', 'Collection Fields Edition Page')
|
||||
cy.get('.field > :nth-child(2) > :nth-child(7)').click()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('category name canceled')
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('taxonomy name canceled')
|
||||
cy.get('.textarea').type('name book canceled description')
|
||||
cy.get('#tainacan-select-status-publish > .check').click()
|
||||
cy.get(':nth-child(1) > .button').click()
|
||||
cy.get('.active-fields-area >').should('not.contain', 'category name canceled')
|
||||
cy.get('.active-fields-area >').should('not.contain', 'taxonomy name canceled')
|
||||
})
|
||||
|
||||
it('create category-type field public - input type = radio', function(){
|
||||
it('create taxonomy-type field public - input type = radio', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
|
||||
cy.location('hash').should('eq', '#/collections')
|
||||
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
|
||||
|
@ -85,16 +85,16 @@ context('Category field test', function(){
|
|||
cy.get('h1').should('contain', 'Collection Fields Edition Page')
|
||||
cy.get('.field > :nth-child(2) > :nth-child(7)').click()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('category name public')
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('taxonomy name public')
|
||||
cy.get('.textarea').type('name book description')
|
||||
cy.get('#tainacan-select-status-publish > .check').click()
|
||||
cy.get(':nth-child(1) > .control > .select > select').select('Cat 1')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Radio').should('have.value', 'tainacan-category-radio')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Radio').should('have.value', 'tainacan-taxonomy-radio')
|
||||
cy.get(':nth-child(2) > .button').click()
|
||||
cy.get('.active-fields-area >').should('contain', 'category name public')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name public')
|
||||
})
|
||||
|
||||
it('create category-type field public - input type = selectbox', function(){
|
||||
it('create taxonomy-type field public - input type = selectbox', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
|
||||
cy.location('hash').should('eq', '#/collections')
|
||||
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
|
||||
|
@ -103,16 +103,16 @@ context('Category field test', function(){
|
|||
cy.get('h1').should('contain', 'Collection Fields Edition Page')
|
||||
cy.get('.field > :nth-child(2) > :nth-child(7)').click()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('category name public')
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('taxonomy name public')
|
||||
cy.get('.textarea').type('name book description')
|
||||
cy.get('#tainacan-select-status-publish > .check').click()
|
||||
cy.get(':nth-child(1) > .control > .select > select').select('Cat 1')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Selectbox').should('have.value', 'tainacan-category-selectbox')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Selectbox').should('have.value', 'tainacan-taxonomy-selectbox')
|
||||
cy.get(':nth-child(2) > .button').click()
|
||||
cy.get('.active-fields-area >').should('contain', 'category name public')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name public')
|
||||
})
|
||||
|
||||
it('create category-type field private', function(){
|
||||
it('create taxonomy-type field private', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
|
||||
cy.location('hash').should('eq', '#/collections')
|
||||
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
|
||||
|
@ -121,16 +121,16 @@ context('Category field test', function(){
|
|||
cy.get('h1').should('contain', 'Collection Fields Edition Page')
|
||||
cy.get('.field > :nth-child(2) > :nth-child(7)').click()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('category name private')
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('taxonomy name private')
|
||||
cy.get('.textarea').type('name book description')
|
||||
cy.get('#tainacan-select-status-private > .check').click()
|
||||
cy.get(':nth-child(1) > .control > .select > select').select('Cat 2')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Radio').should('have.value', 'tainacan-category-radio')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Radio').should('have.value', 'tainacan-taxonomy-radio')
|
||||
cy.get(':nth-child(2) > .button').click()
|
||||
cy.get('.active-fields-area >').should('contain', 'category name private')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name private')
|
||||
})
|
||||
|
||||
it('create category-type field public required', function(){
|
||||
it('create taxonomy-type field public required', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
|
||||
cy.location('hash').should('eq', '#/collections')
|
||||
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
|
||||
|
@ -139,16 +139,16 @@ context('Category field test', function(){
|
|||
cy.get('h1').should('contain', 'Collection Fields Edition Page')
|
||||
cy.get('.field > :nth-child(2) > :nth-child(7)').click()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('category name public required')
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('taxonomy name public required')
|
||||
cy.get('.textarea').type('name book description required')
|
||||
cy.get('#tainacan-select-status-publish > .check').click()
|
||||
cy.get(':nth-child(1) > .control > .select > select').select('Cat 3')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Radio').should('have.value', 'tainacan-category-radio')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Radio').should('have.value', 'tainacan-taxonomy-radio')
|
||||
cy.get(':nth-child(2) > .button').click()
|
||||
cy.get('.active-fields-area >').should('contain', 'category name public required')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name public required')
|
||||
})
|
||||
|
||||
it('create category-type field public multiple values', function(){
|
||||
it('create taxonomy-type field public multiple values', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
|
||||
cy.location('hash').should('eq', '#/collections')
|
||||
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
|
||||
|
@ -157,16 +157,16 @@ context('Category field test', function(){
|
|||
cy.get('h1').should('contain', 'Collection Fields Edition Page')
|
||||
cy.get('.field > :nth-child(2) > :nth-child(7)').click()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('category name public multiple values')
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('taxonomy name public multiple values')
|
||||
cy.get('.textarea').type('name book description multiple values')
|
||||
cy.get('#tainacan-select-status-publish > .check').click()
|
||||
cy.get(':nth-child(1) > .control > .select > select').select('Cat 4')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Radio').should('have.value', 'tainacan-category-radio')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Radio').should('have.value', 'tainacan-taxonomy-radio')
|
||||
cy.get(':nth-child(2) > .button').click()
|
||||
cy.get('.active-fields-area >').should('contain', 'category name public multiple values')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name public multiple values')
|
||||
})
|
||||
|
||||
it('create category-type field public unique values', function(){
|
||||
it('create taxonomy-type field public unique values', function(){
|
||||
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
|
||||
cy.location('hash').should('eq', '#/collections')
|
||||
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
|
||||
|
@ -175,13 +175,13 @@ context('Category field test', function(){
|
|||
cy.get('h1').should('contain', 'Collection Fields Edition Page')
|
||||
cy.get('.field > :nth-child(2) > :nth-child(7)').click()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('category name public unique values')
|
||||
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('taxonomy 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(1) > .control > .select > select').select('Cat 5')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Radio').should('have.value', 'tainacan-category-radio')
|
||||
cy.get(':nth-child(2) > .control > .select > select').select('Radio').should('have.value', 'tainacan-taxonomy-radio')
|
||||
cy.get(':nth-child(2) > .button').click()
|
||||
cy.get('.active-fields-area >').should('contain', 'category name public unique values')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name public unique values')
|
||||
})
|
||||
|
||||
it('check if fields are updated to page', function(){
|
||||
|
@ -191,11 +191,11 @@ context('Category field test', function(){
|
|||
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
|
||||
cy.get('.menu > :nth-child(2) > :nth-child(7) > a').click()
|
||||
cy.get('h1').should('contain', 'Collection Fields Edition Page')
|
||||
cy.get('.active-fields-area >').should('not.contain', 'category name canceled')
|
||||
cy.get('.active-fields-area >').should('contain', 'category name public')
|
||||
cy.get('.active-fields-area >').should('contain', 'category name private')
|
||||
cy.get('.active-fields-area >').should('contain', 'category name public required')
|
||||
cy.get('.active-fields-area >').should('contain', 'category name public multiple values')
|
||||
cy.get('.active-fields-area >').should('contain', 'category name public unique values')
|
||||
cy.get('.active-fields-area >').should('not.contain', 'taxonomy name canceled')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name public')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name private')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name public required')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name public multiple values')
|
||||
cy.get('.active-fields-area >').should('contain', 'taxonomy name public unique values')
|
||||
})
|
||||
})
|
||||
|
|
|
@ -175,18 +175,18 @@ Fetch all values of a metadatum from a collection in all it collection items
|
|||
|
||||
**Returns:** array|null|object
|
||||
|
||||
### `private function pre_update_category_field($metadatum)`
|
||||
### `private function pre_update_taxonomy_field($metadatum)`
|
||||
|
||||
Stores the value of the taxonomy_id option to use on update_category_field method.
|
||||
Stores the value of the taxonomy_id option to use on update_taxonomy_field method.
|
||||
|
||||
|
||||
|
||||
|
||||
### `private function update_category_field($metadatum)`
|
||||
### `private function update_taxonomy_field($metadatum)`
|
||||
|
||||
Triggers hooks when saving a Category Metadatum, indicating wich taxonomy was added or removed from a collection.
|
||||
Triggers hooks when saving a Taxonomy Metadatum, indicating wich taxonomy was added or removed from a collection.
|
||||
|
||||
This is used by Taxonomies repository to update the collections_ids property of the taxonomy as a metadatum type category is inserted or removed
|
||||
This is used by Taxonomies repository to update the collections_ids property of the taxonomy as a metadatum type taxonomy is inserted or removed
|
||||
|
||||
|
||||
**Parameters:**
|
||||
|
|
|
@ -11,7 +11,7 @@ The typical workflow when you create a Digital Repository with Tainacan is:
|
|||
|
||||
A collection is a group of items, that share the same set of metadata. Every item uploaded to your digital repository will be part of a collection - and only one collection. For instance, you could have a "paintings" collections, with metadata such as Title, Author, Country, Tecnique, etc and another collection for "films", with Title, Director, Country and Genre.
|
||||
|
||||
For each collection you can set a different set of metadata and they can share common categories, which means you could browse for items in a specific Country, and get both paintings and films in your results.
|
||||
For each collection you can set a different set of metadata and they can share common taxonomies, which means you could browse for items in a specific Country, and get both paintings and films in your results.
|
||||
|
||||
Collections can also have child collections, which will inherit parent's collection metadata and can add their own set of additional information.
|
||||
|
||||
|
@ -69,7 +69,7 @@ Taxonomies can be created and used to classify items. Typical Taxonomies are Gen
|
|||
|
||||
In WordPress language, they are Custom Taxonomies, and they can be shared among many collections.
|
||||
|
||||
Each Category has a set of terms. For example, the category Genre may have terms like "drama" and "comedy".
|
||||
Each Taxonomy has a set of terms. For example, the taxonomy Genre may have terms like "drama" and "comedy".
|
||||
|
||||
Terms can have hierarchy, which means that when you browse for items that have a parente term (for instance, "Rock"), the results will include items that have any of the child terms (for instance, "Progressive Rock" and "Classic Rock").
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ Who's got it: Administrators, Editors and Tainacan Editors
|
|||
Allows to view Items marked as private and its items.
|
||||
|
||||
|
||||
### Categories
|
||||
### Taxonomies
|
||||
|
||||
### Metadata
|
||||
|
||||
|
|
|
@ -1,370 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="page-container primary-page">
|
||||
<tainacan-title />
|
||||
<b-tabs v-model="activeTab">
|
||||
<b-tab-item :label="$i18n.get('taxonomy')">
|
||||
<form
|
||||
v-if="category != null && category != undefined"
|
||||
class="tainacan-form"
|
||||
label-width="120px">
|
||||
|
||||
<!-- Name -------------------------------- -->
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_name')"
|
||||
:type="editFormErrors['name'] != undefined ? 'is-danger' : ''"
|
||||
:message="editFormErrors['name'] != undefined ? editFormErrors['name'] : ''">
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('categories', 'name')"
|
||||
:message="$i18n.getHelperMessage('categories', 'name')"/>
|
||||
<b-input
|
||||
id="tainacan-text-name"
|
||||
v-model="form.name"
|
||||
@focus="clearErrors('name')"
|
||||
@blur="updateSlug()"/>
|
||||
</b-field>
|
||||
|
||||
<!-- Description -------------------------------- -->
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_description')"
|
||||
:type="editFormErrors['description'] != undefined ? 'is-danger' : ''"
|
||||
:message="editFormErrors['description'] != undefined ? editFormErrors['description'] : ''">
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('categories', 'description')"
|
||||
:message="$i18n.getHelperMessage('categories', 'description')"/>
|
||||
<b-input
|
||||
id="tainacan-text-description"
|
||||
type="textarea"
|
||||
v-model="form.description"
|
||||
@focus="clearErrors('description')"/>
|
||||
</b-field>
|
||||
|
||||
<!-- Status -------------------------------- -->
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_status')"
|
||||
:type="editFormErrors['status'] != undefined ? 'is-danger' : ''"
|
||||
:message="editFormErrors['status'] != undefined ? editFormErrors['status'] : ''">
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('categories', 'status')"
|
||||
:message="$i18n.getHelperMessage('categories', 'status')"/>
|
||||
<b-select
|
||||
id="tainacan-select-status"
|
||||
v-model="form.status"
|
||||
@focus="clearErrors('status')"
|
||||
:placeholder="$i18n.get('instruction_select_a_status')">
|
||||
<option
|
||||
v-for="statusOption in statusOptions"
|
||||
:key="statusOption.value"
|
||||
:value="statusOption.value"
|
||||
:disabled="statusOption.disabled">{{ statusOption.label }}
|
||||
</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
<!-- Slug -------------------------------- -->
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_slug')"
|
||||
:type="editFormErrors['slug'] != undefined ? 'is-danger' : ''"
|
||||
:message="editFormErrors['slug'] != undefined ? editFormErrors['slug'] : ''">
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('categories', 'slug')"
|
||||
:message="$i18n.getHelperMessage('categories', 'slug')"/>
|
||||
<b-icon :class="{'is-loading': isUpdatingSlug}"/>
|
||||
<b-input
|
||||
@input="updateSlug()"
|
||||
id="tainacan-text-slug"
|
||||
v-model="form.slug"
|
||||
@focus="clearErrors('slug')"
|
||||
:disabled="isUpdatingSlug"/>
|
||||
</b-field>
|
||||
|
||||
<!-- Allow Insert -->
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_category_allow_new_terms')">
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('categories', 'allow_insert')"
|
||||
:message="$i18n.getHelperMessage('categories', 'allow_insert')"/>
|
||||
<div class="block" >
|
||||
<b-checkbox
|
||||
v-model="form.allowInsert"
|
||||
true-value="yes"
|
||||
false-value="no">
|
||||
{{ labelNewTerms() }}
|
||||
</b-checkbox>
|
||||
</div>
|
||||
</b-field>
|
||||
|
||||
<!-- Submit -->
|
||||
<div class="field is-grouped form-submit">
|
||||
<div class="control">
|
||||
<button
|
||||
id="button-cancel-category-creation"
|
||||
class="button is-outlined"
|
||||
type="button"
|
||||
@click="cancelBack">{{ $i18n.get('cancel') }}</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button
|
||||
id="button-submit-category-creation"
|
||||
@click.prevent="onSubmit"
|
||||
class="button is-success">{{ $i18n.get('save') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help is-danger">{{ formErrorMessage }}</p>
|
||||
</form>
|
||||
</b-tab-item>
|
||||
|
||||
<b-tab-item :label="$i18n.get('terms')">
|
||||
<!-- Terms List -->
|
||||
<terms-list :category-id="categoryId"/>
|
||||
</b-tab-item>
|
||||
|
||||
<b-loading
|
||||
:active.sync="isLoadingCategory"
|
||||
:can-cancel="false"/>
|
||||
</b-tabs>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { wpAjax } from "../../js/mixins";
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import TermsList from '../lists/terms-list.vue'
|
||||
import htmlToJSON from 'html-to-json';
|
||||
import CustomDialog from '../other/custom-dialog.vue';
|
||||
|
||||
export default {
|
||||
name: 'CategoryEditionForm',
|
||||
mixins: [ wpAjax ],
|
||||
data(){
|
||||
return {
|
||||
categoryId: String,
|
||||
activeTab: 0,
|
||||
category: null,
|
||||
isLoadingCategory: false,
|
||||
isUpdatingSlug: false,
|
||||
form: {
|
||||
name: String,
|
||||
status: String,
|
||||
description: String,
|
||||
slug: String,
|
||||
allowInsert: String
|
||||
},
|
||||
statusOptions: [{
|
||||
value: 'publish',
|
||||
label: this.$i18n.get('publish')
|
||||
}, {
|
||||
value: 'draft',
|
||||
label: this.$i18n.get('draft')
|
||||
}, {
|
||||
value: 'private',
|
||||
label: this.$i18n.get('private')
|
||||
}, {
|
||||
value: 'trash',
|
||||
label: this.$i18n.get('trash')
|
||||
}],
|
||||
editFormErrors: {},
|
||||
formErrorMessage: '',
|
||||
// baseUrl: tainacan_plugin.base_url,
|
||||
}
|
||||
},
|
||||
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.$modal.open({
|
||||
parent: this,
|
||||
component: CustomDialog,
|
||||
props: {
|
||||
icon: 'alert',
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_category_not_saved'),
|
||||
onConfirm: () => {
|
||||
next();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('category', [
|
||||
'createCategory',
|
||||
'updateCategory',
|
||||
'fetchCategory',
|
||||
'fetchOnlySlug'
|
||||
]),
|
||||
...mapGetters('category',[
|
||||
'getCategory',
|
||||
]),
|
||||
onSubmit() {
|
||||
|
||||
this.isLoadingCategory = true;
|
||||
|
||||
let data = {
|
||||
categoryId: this.categoryId,
|
||||
name: this.form.name,
|
||||
description: this.form.description,
|
||||
slug: this.form.slug,
|
||||
status: this.form.status,
|
||||
allowInsert: this.form.allowInsert
|
||||
};
|
||||
|
||||
this.updateCategory(data)
|
||||
.then(updatedCategory => {
|
||||
|
||||
this.category = updatedCategory;
|
||||
|
||||
// Fill this.form data with current data.
|
||||
this.form.name = this.category.name;
|
||||
this.form.slug = this.category.slug;
|
||||
this.form.description = this.category.description;
|
||||
this.form.status = this.category.status;
|
||||
this.form.allowInsert = this.category.allow_insert;
|
||||
|
||||
this.isLoadingCategory = false;
|
||||
this.formErrorMessage = '';
|
||||
this.editFormErrors = {};
|
||||
|
||||
this.$router.push(this.$routerHelper.getCategoriesPath());
|
||||
})
|
||||
.catch((errors) => {
|
||||
for (let error of errors.errors) {
|
||||
for (let attribute of Object.keys(error)) {
|
||||
this.editFormErrors[attribute] = error[attribute];
|
||||
}
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
|
||||
this.isLoadingCategory = false;
|
||||
});
|
||||
},
|
||||
updateSlug(){
|
||||
if(!this.form.name || this.form.name.length <= 0){
|
||||
return;
|
||||
}
|
||||
|
||||
this.isUpdatingSlug = true;
|
||||
|
||||
this.getSamplePermalink(this.categoryId, this.form.name, this.form.slug)
|
||||
.then(samplePermalink => {
|
||||
|
||||
let promise = htmlToJSON.parse(samplePermalink, {
|
||||
permalink($doc) {
|
||||
return $doc.find('#editable-post-name-full').text();
|
||||
}
|
||||
});
|
||||
|
||||
promise.done((result) => {
|
||||
this.form.slug = result.permalink;
|
||||
//this.$console.info(this.form.slug);
|
||||
});
|
||||
|
||||
this.isUpdatingSlug = false;
|
||||
this.formErrorMessage = '';
|
||||
this.editFormErrors = {};
|
||||
})
|
||||
.catch(errors => {
|
||||
this.$console.error(errors);
|
||||
|
||||
this.isUpdatingSlug = false;
|
||||
});
|
||||
|
||||
},
|
||||
createNewCategory() {
|
||||
// Puts loading on Draft Category creation
|
||||
this.isLoadingCategory = true;
|
||||
|
||||
// Creates draft Category
|
||||
let data = {
|
||||
name: '',
|
||||
description: '',
|
||||
status: 'auto-draft',
|
||||
slug: '',
|
||||
allowInsert: '',
|
||||
};
|
||||
|
||||
this.createCategory(data)
|
||||
.then(res => {
|
||||
|
||||
this.categoryId = res.id;
|
||||
this.category = res;
|
||||
|
||||
// Fill this.form data with current data.
|
||||
this.form.name = this.category.name;
|
||||
this.form.description = this.category.description;
|
||||
this.form.slug = this.category.slug;
|
||||
this.form.allowInsert = this.category.allow_insert;
|
||||
|
||||
// Pre-fill status with publish to incentivate it
|
||||
this.form.status = 'publish';
|
||||
|
||||
this.isLoadingCategory = false;
|
||||
|
||||
})
|
||||
.catch(error => this.$console.error(error));
|
||||
},
|
||||
clearErrors(attribute) {
|
||||
this.editFormErrors[attribute] = undefined;
|
||||
},
|
||||
cancelBack(){
|
||||
this.$router.push(this.$routerHelper.getCategoriesPath());
|
||||
},
|
||||
labelNewTerms(){
|
||||
return ( this.form.allowInsert === 'yes' ) ? this.$i18n.get('label_yes') : this.$i18n.get('label_no');
|
||||
}
|
||||
},
|
||||
created(){
|
||||
|
||||
if (this.$route.fullPath.split("/").pop() === "new") {
|
||||
this.createNewCategory();
|
||||
} else if (this.$route.fullPath.split("/").pop() === "edit" || this.$route.fullPath.split("/").pop() === "terms") {
|
||||
|
||||
this.isLoadingCategory = true;
|
||||
|
||||
// Obtains current category ID from URL
|
||||
this.pathArray = this.$route.fullPath.split("/").reverse();
|
||||
this.categoryId = this.pathArray[1];
|
||||
|
||||
this.fetchCategory(this.categoryId).then(res => {
|
||||
this.category = res.category;
|
||||
|
||||
// Fill this.form data with current data.
|
||||
this.form.name = this.category.name;
|
||||
this.form.description = this.category.description;
|
||||
this.form.slug = this.category.slug;
|
||||
this.form.status = this.category.status;
|
||||
this.form.allowInsert = this.category.allow_insert;
|
||||
|
||||
this.isLoadingCategory = false;
|
||||
});
|
||||
|
||||
if (this.$route.fullPath.split("/").pop() === "terms")
|
||||
this.activeTab = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
@ -121,21 +121,21 @@
|
|||
},
|
||||
props: {
|
||||
editForm: Object,
|
||||
categoryId: ''
|
||||
taxonomyId: ''
|
||||
},
|
||||
methods: {
|
||||
...mapActions('category', [
|
||||
...mapActions('taxonomy', [
|
||||
'sendTerm',
|
||||
'updateTerm',
|
||||
]),
|
||||
...mapGetters('category', [
|
||||
...mapGetters('taxonomy', [
|
||||
'getTerms'
|
||||
]),
|
||||
saveEdition(term) {
|
||||
|
||||
if (term.id === 'new') {
|
||||
this.sendTerm({
|
||||
categoryId: this.categoryId,
|
||||
taxonomyId: this.taxonomyId,
|
||||
name: this.editForm.name,
|
||||
description: this.editForm.description,
|
||||
parent: this.editForm.parent,
|
||||
|
@ -157,7 +157,7 @@
|
|||
|
||||
} else {
|
||||
this.updateTerm({
|
||||
categoryId: this.categoryId,
|
||||
taxonomyId: this.taxonomyId,
|
||||
termId: this.editForm.id,
|
||||
name: this.editForm.name,
|
||||
description: this.editForm.description,
|
||||
|
|
|
@ -1,287 +0,0 @@
|
|||
<template>
|
||||
<div
|
||||
v-if="totalCategories > 0 && !isLoading"
|
||||
class="table-container">
|
||||
|
||||
<div class="selection-control">
|
||||
<div class="field select-all is-pulled-left">
|
||||
<span>
|
||||
<b-checkbox
|
||||
@click.native="selectAllCategoriesOnPage()"
|
||||
:value="allCategoriesOnPageSelected">{{ $i18n.get('label_select_all_categories_page') }}</b-checkbox>
|
||||
</span>
|
||||
</div>
|
||||
<div class="field is-pulled-right">
|
||||
<b-dropdown
|
||||
position="is-bottom-left"
|
||||
v-if="categories[0].current_user_can_edit"
|
||||
:disabled="!isSelectingCategories"
|
||||
id="bulk-actions-dropdown">
|
||||
<button
|
||||
class="button is-white"
|
||||
slot="trigger">
|
||||
<span>{{ $i18n.get('label_bulk_actions') }}</span>
|
||||
<b-icon icon="menu-down"/>
|
||||
</button>
|
||||
|
||||
<b-dropdown-item
|
||||
id="item-delete-selected-items"
|
||||
@click="deleteSelectedCategories()">
|
||||
{{ $i18n.get('label_delete_selected_categories') }}
|
||||
</b-dropdown-item>
|
||||
<b-dropdown-item disabled>{{ $i18n.get('label_edit_selected_categories') + ' (Not ready)' }}
|
||||
</b-dropdown-item>
|
||||
</b-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="table-wrapper">
|
||||
<table class="tainacan-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- Checking list -->
|
||||
<th>
|
||||
|
||||
<!-- nothing to show on header -->
|
||||
</th>
|
||||
<!-- Name -->
|
||||
<th>
|
||||
<div class="th-wrap">{{ $i18n.get('label_name') }}</div>
|
||||
</th>
|
||||
<!-- Description -->
|
||||
<th>
|
||||
<div class="th-wrap">{{ $i18n.get('label_description') }}</div>
|
||||
</th>
|
||||
<!-- Actions -->
|
||||
<th class="actions-header">
|
||||
|
||||
<!-- nothing to show on header for actions cell-->
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
:class="{ 'selected-row': selectedCategories[index] }"
|
||||
:key="index"
|
||||
v-for="(category, index) of categories">
|
||||
<!-- Checking list -->
|
||||
<td
|
||||
:class="{ 'is-selecting': isSelectingCategories }"
|
||||
class="checkbox-cell">
|
||||
<b-checkbox
|
||||
size="is-small"
|
||||
v-model="selectedCategories[index]"/>
|
||||
</td>
|
||||
<!-- Name -->
|
||||
<td
|
||||
class="column-default-width column-main-content"
|
||||
@click="goToCategoryEditPage(category.id)"
|
||||
:label="$i18n.get('label_name')"
|
||||
:aria-label="$i18n.get('label_name') + ': ' + category.name">
|
||||
<p
|
||||
v-tooltip="{
|
||||
content: category.name,
|
||||
autoHide: false,
|
||||
placement: 'auto-start'
|
||||
}">
|
||||
{{ category.name }}</p>
|
||||
</td>
|
||||
<!-- Description -->
|
||||
<td
|
||||
class="column-large-width"
|
||||
@click="goToCategoryEditPage(category.id)"
|
||||
:label="$i18n.get('label_description')"
|
||||
:aria-label="$i18n.get('label_description') + ': ' + category.description">
|
||||
<p
|
||||
v-tooltip="{
|
||||
content: category.description,
|
||||
autoHide: false,
|
||||
placement: 'auto-start'
|
||||
}">
|
||||
{{ category.description }}</p>
|
||||
</td>
|
||||
<!-- Actions -->
|
||||
<td
|
||||
@click="goToCategoryEditPage(category.id)"
|
||||
class="actions-cell column-default-width"
|
||||
:label="$i18n.get('label_actions')">
|
||||
<div class="actions-container">
|
||||
<a
|
||||
id="button-edit"
|
||||
:aria-label="$i18n.getFrom('categories','edit_item')"
|
||||
@click="goToCategoryEditPage(category.id)">
|
||||
<b-icon
|
||||
type="is-secondary"
|
||||
icon="pencil"/>
|
||||
</a>
|
||||
<a
|
||||
id="button-delete"
|
||||
:aria-label="$i18n.get('label_button_delete')"
|
||||
@click.prevent.stop="deleteOneCategory(category.id)">
|
||||
<b-icon
|
||||
type="is-secondary"
|
||||
icon="delete"/>
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex';
|
||||
import CustomDialog from '../other/custom-dialog.vue';
|
||||
|
||||
export default {
|
||||
name: 'CategoriesList',
|
||||
data() {
|
||||
return {
|
||||
selectedCategories: [],
|
||||
allCategoriesOnPageSelected: false,
|
||||
isSelectingCategories: false
|
||||
}
|
||||
},
|
||||
props: {
|
||||
isLoading: false,
|
||||
totalCategories: 0,
|
||||
page: 1,
|
||||
categoriesPerPage: 12,
|
||||
categories: Array
|
||||
},
|
||||
watch: {
|
||||
categories() {
|
||||
this.selectedCategories = [];
|
||||
for (let i = 0; i < this.categories.length; i++)
|
||||
this.selectedCategories.push(false);
|
||||
},
|
||||
selectedCategories() {
|
||||
let allSelected = true;
|
||||
let isSelecting = false;
|
||||
for (let i = 0; i < this.selectedCategories.length; i++) {
|
||||
if (this.selectedCategories[i] == false) {
|
||||
allSelected = false;
|
||||
} else {
|
||||
isSelecting = true;
|
||||
}
|
||||
}
|
||||
this.allCategoriesOnPageSelected = allSelected;
|
||||
this.isSelectingCategories = isSelecting;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('category', [
|
||||
'deleteCategory'
|
||||
]),
|
||||
selectAllCategoriesOnPage() {
|
||||
for (let i = 0; i < this.selectedCategories.length; i++)
|
||||
this.selectedCategories.splice(i, 1, !this.allCategoriesOnPageSelected);
|
||||
},
|
||||
deleteOneCategory(categoryId) {
|
||||
this.$modal.open({
|
||||
parent: this,
|
||||
component: CustomDialog,
|
||||
props: {
|
||||
icon: 'alert',
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_category_delete'),
|
||||
onConfirm: () => {
|
||||
this.deleteCategory(categoryId)
|
||||
.then(() => {
|
||||
// this.$toast.open({
|
||||
// duration: 3000,
|
||||
// message: this.$i18n.get('info_category_deleted'),
|
||||
// position: 'is-bottom',
|
||||
// type: 'is-secondary',
|
||||
// queue: true
|
||||
// });
|
||||
for (let i = 0; i < this.selectedCategories.length; i++) {
|
||||
if (this.selectedCategories[i].id === this.categoryId)
|
||||
this.selectedCategories.splice(i, 1);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// this.$toast.open({
|
||||
// duration: 3000,
|
||||
// message: this.$i18n.get('info_error_deleting_category'),
|
||||
// position: 'is-bottom',
|
||||
// type: 'is-danger',
|
||||
// queue: true
|
||||
// });
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
deleteSelectedCategories() {
|
||||
this.$modal.open({
|
||||
parent: this,
|
||||
component: CustomDialog,
|
||||
props: {
|
||||
icon: 'alert',
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_selected_categories_delete'),
|
||||
onConfirm: () => {
|
||||
|
||||
for (let i = 0; i < this.categories.length; i++) {
|
||||
if (this.selectedCategories[i]) {
|
||||
this.deleteCategory(this.categories[i].id)
|
||||
.then(() => {
|
||||
// this.loadCategories();
|
||||
// this.$toast.open({
|
||||
// duration: 3000,
|
||||
// message: this.$i18n.get('info_category_deleted'),
|
||||
// position: 'is-bottom',
|
||||
// type: 'is-secondary',
|
||||
// queue: false
|
||||
// })
|
||||
}).catch(() => {
|
||||
// this.$toast.open({
|
||||
// duration: 3000,
|
||||
// message: this.$i18n.get('info_error_deleting_category'),
|
||||
// position: 'is-bottom',
|
||||
// type: 'is-danger',
|
||||
// queue: false
|
||||
// });
|
||||
});
|
||||
}
|
||||
}
|
||||
this.allCategoriesOnPageSelected = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
goToCategoryPage(categoryId) {
|
||||
this.$router.push(this.$routerHelper.getCategoryPath(categoryId));
|
||||
},
|
||||
goToCategoryEditPage(categoryId) {
|
||||
this.$router.push(this.$routerHelper.getCategoryEditPath(categoryId));
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@import "../../scss/_variables.scss";
|
||||
|
||||
.selection-control {
|
||||
|
||||
padding: 6px 0px 0px 13px;
|
||||
background: white;
|
||||
height: 40px;
|
||||
|
||||
.select-all {
|
||||
color: $gray-light;
|
||||
font-size: 14px;
|
||||
&:hover {
|
||||
color: $gray-light;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<div>
|
||||
<b-field
|
||||
:addons="false"
|
||||
:label="$i18n.get('label_category_terms')">
|
||||
:label="$i18n.get('label_taxonomy_terms')">
|
||||
<button
|
||||
class="button is-secondary is-pulled-right"
|
||||
type="button"
|
||||
|
@ -41,7 +41,7 @@
|
|||
<button
|
||||
class="button is-success is-small"
|
||||
type="button"
|
||||
:href="categoryPath + '/' + term.slug">
|
||||
:href="taxonomyPath + '/' + term.slug">
|
||||
{{ $i18n.get('label_view_term') }}
|
||||
</button>
|
||||
-->
|
||||
|
@ -69,7 +69,7 @@
|
|||
</span>
|
||||
<div v-show="term.opened">
|
||||
<term-edition-form
|
||||
:category-id="categoryId"
|
||||
:taxonomy-id="taxonomyId"
|
||||
@onEditionFinished="onTermEditionFinished()"
|
||||
@onEditionCanceled="onTermEditionCanceled(term)"
|
||||
@onErrorFound="formWithErrors = term.id"
|
||||
|
@ -98,8 +98,8 @@ export default {
|
|||
}
|
||||
},
|
||||
props: {
|
||||
categoryId: String,
|
||||
//categoryPath: ''
|
||||
taxonomyId: String,
|
||||
//taxonomyPath: ''
|
||||
},
|
||||
computed: {
|
||||
termsList() {
|
||||
|
@ -110,7 +110,7 @@ export default {
|
|||
termsList() {
|
||||
this.generateOrderedTerms();
|
||||
},
|
||||
categoryId() {
|
||||
taxonomyId() {
|
||||
this.loadTerms();
|
||||
}
|
||||
},
|
||||
|
@ -118,17 +118,17 @@ export default {
|
|||
TermEditionForm
|
||||
},
|
||||
methods: {
|
||||
...mapActions('category', [
|
||||
...mapActions('taxonomy', [
|
||||
'updateTerm',
|
||||
'deleteTerm',
|
||||
'fetchTerms'
|
||||
]),
|
||||
...mapGetters('category',[
|
||||
...mapGetters('taxonomy',[
|
||||
'getTerms'
|
||||
]),
|
||||
addNewTerm() {
|
||||
let newTerm = {
|
||||
categoryId: this.categoryId,
|
||||
taxonomyId: this.taxonomyId,
|
||||
name: this.$i18n.get('label_term_without_name'),
|
||||
description: '',
|
||||
parent: 0,
|
||||
|
@ -141,7 +141,7 @@ export default {
|
|||
},
|
||||
addNewChildTerm(parent, parentIndex) {
|
||||
let newTerm = {
|
||||
categoryId: this.categoryId,
|
||||
taxonomyId: this.taxonomyId,
|
||||
name: this.$i18n.get('label_term_without_name'),
|
||||
description: '',
|
||||
parent: parent.id,
|
||||
|
@ -238,7 +238,7 @@ export default {
|
|||
}
|
||||
} else {
|
||||
|
||||
this.deleteTerm({categoryId: this.categoryId, termId: term.id})
|
||||
this.deleteTerm({taxonomyId: this.taxonomyId, termId: term.id})
|
||||
.then(() => {
|
||||
|
||||
})
|
||||
|
@ -250,7 +250,7 @@ export default {
|
|||
for (let orphanTerm of this.termsList) {
|
||||
if (orphanTerm.parent == term.id) {
|
||||
this.updateTerm({
|
||||
categoryId: this.categoryId,
|
||||
taxonomyId: this.taxonomyId,
|
||||
termId: orphanTerm.id,
|
||||
name: orphanTerm.name,
|
||||
description: orphanTerm.description,
|
||||
|
@ -314,7 +314,7 @@ export default {
|
|||
},
|
||||
loadTerms() {
|
||||
this.isLoadingTerms = true;
|
||||
this.fetchTerms(this.categoryId)
|
||||
this.fetchTerms(this.taxonomyId)
|
||||
.then(() => {
|
||||
// Fill this.form data with current data.
|
||||
this.isLoadingTerms = false;
|
||||
|
@ -326,7 +326,7 @@ export default {
|
|||
}
|
||||
},
|
||||
created() {
|
||||
if (this.categoryId !== String) {
|
||||
if (this.taxonomyId !== String) {
|
||||
this.loadTerms();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<b-icon
|
||||
size="is-small"
|
||||
icon="shape"/>
|
||||
<span class="menu-text">{{ $i18n.getFrom('categories', 'name') }}</span>
|
||||
<span class="menu-text">{{ $i18n.getFrom('taxonomies', 'name') }}</span>
|
||||
</router-link>
|
||||
</li>
|
||||
<li>
|
||||
|
|
|
@ -141,11 +141,11 @@ export default {
|
|||
...mapGetters('item', [
|
||||
'getItemTitle'
|
||||
]),
|
||||
...mapActions('category', [
|
||||
'fetchCategoryName'
|
||||
...mapActions('taxonomy', [
|
||||
'fetchTaxonomyName'
|
||||
]),
|
||||
...mapGetters('category', [
|
||||
'getCategoryName'
|
||||
...mapGetters('taxonomy', [
|
||||
'getTaxonomyName'
|
||||
]),
|
||||
...mapActions('event', [
|
||||
'fetchEventTitle'
|
||||
|
@ -171,8 +171,8 @@ export default {
|
|||
.catch((error) => this.$console.error(error));
|
||||
break;
|
||||
case 'taxonomies':
|
||||
this.fetchCategoryName(this.arrayRealPath[i])
|
||||
.then(categoryName => this.arrayViewPath.splice(i, 1, categoryName))
|
||||
this.fetchTaxonomyName(this.arrayRealPath[i])
|
||||
.then(taxonomyName => this.arrayViewPath.splice(i, 1, taxonomyName))
|
||||
.catch((error) => this.$console.error(error));
|
||||
break;
|
||||
case 'events':
|
||||
|
|
|
@ -58,11 +58,11 @@ export default {
|
|||
...mapGetters('item', [
|
||||
'getItemTitle'
|
||||
]),
|
||||
...mapActions('category', [
|
||||
'fetchCategoryName'
|
||||
...mapActions('taxonomy', [
|
||||
'fetchTaxonomyName'
|
||||
]),
|
||||
...mapGetters('category', [
|
||||
'getCategoryName'
|
||||
...mapGetters('taxonomy', [
|
||||
'getTaxonomyName'
|
||||
]),
|
||||
...mapActions('event', [
|
||||
'fetchEventTitle'
|
||||
|
@ -87,8 +87,8 @@ export default {
|
|||
.catch((error) => this.$console.error(error));
|
||||
break;
|
||||
case 'taxonomies':
|
||||
this.fetchCategoryName(this.arrayRealPath[i])
|
||||
.then(categoryName => this.arrayViewPath.splice(i, 1, categoryName))
|
||||
this.fetchTaxonomyName(this.arrayRealPath[i])
|
||||
.then(taxonomyName => this.arrayViewPath.splice(i, 1, taxonomyName))
|
||||
.catch((error) => this.$console.error(error));
|
||||
break;
|
||||
case 'events':
|
||||
|
|
|
@ -14,10 +14,10 @@ import Selectbox from '../../classes/metadata-types/selectbox/Selectbox.vue';
|
|||
import Numeric from '../../classes/metadata-types/numeric/Numeric.vue';
|
||||
import Date from '../../classes/metadata-types/date/Date.vue';
|
||||
import Relationship from '../../classes/metadata-types/relationship/Relationship.vue';
|
||||
import Category from '../../classes/metadata-types/category/Category.vue';
|
||||
import Taxonomy from '../../classes/metadata-types/taxonomy/Taxonomy.vue';
|
||||
|
||||
import FormRelationship from '../../classes/metadata-types/relationship/FormRelationship.vue';
|
||||
import FormCategory from '../../classes/metadata-types/category/FormCategory.vue';
|
||||
import FormTaxonomy from '../../classes/metadata-types/taxonomy/FormTaxonomy.vue';
|
||||
import FormSelectbox from '../../classes/metadata-types/selectbox/FormSelectbox.vue';
|
||||
|
||||
import FilterCustomInterval from '../../classes/filter-types/custom-interval/CustomInterval.vue';
|
||||
|
@ -26,9 +26,9 @@ import FilterAutocomplete from '../../classes/filter-types/autocomplete/Autocomp
|
|||
import FilterCheckbox from '../../classes/filter-types/checkbox/Checkbox.vue';
|
||||
import FilterTaginput from '../../classes/filter-types/taginput/Taginput.vue';
|
||||
|
||||
import FilterCategoryCheckbox from '../../classes/filter-types/category/Checkbox.vue';
|
||||
import FilterCategoryTaginput from '../../classes/filter-types/category/Taginput.vue';
|
||||
import FilterCategorySelectbox from '../../classes/filter-types/category/Selectbox.vue';
|
||||
import FilterTaxonomyCheckbox from '../../classes/filter-types/taxonomy/Checkbox.vue';
|
||||
import FilterTaxonomyTaginput from '../../classes/filter-types/taxonomy/Taginput.vue';
|
||||
import FilterTaxonomySelectbox from '../../classes/filter-types/taxonomy/Selectbox.vue';
|
||||
|
||||
import TainacanFormItem from '../../classes/metadata-types/tainacan-form-item.vue';
|
||||
import TainacanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue';
|
||||
|
@ -61,10 +61,10 @@ Vue.component('tainacan-selectbox', Selectbox);
|
|||
Vue.component('tainacan-numeric', Numeric);
|
||||
Vue.component('tainacan-date', Date);
|
||||
Vue.component('tainacan-relationship', Relationship);
|
||||
Vue.component('tainacan-category', Category);
|
||||
Vue.component('tainacan-taxonomy', Taxonomy);
|
||||
|
||||
Vue.component('tainacan-form-relationship', FormRelationship);
|
||||
Vue.component('tainacan-form-category', FormCategory);
|
||||
Vue.component('tainacan-form-taxonomy', FormTaxonomy);
|
||||
Vue.component('tainacan-form-selectbox', FormSelectbox);
|
||||
Vue.component('tainacan-form-item', TainacanFormItem);
|
||||
Vue.component('tainacan-filter-item', TainacanFiltersList);
|
||||
|
@ -75,9 +75,9 @@ Vue.component('tainacan-filter-selectbox', FilterSelectbox);
|
|||
Vue.component('tainacan-filter-autocomplete', FilterAutocomplete);
|
||||
Vue.component('tainacan-filter-checkbox', FilterCheckbox);
|
||||
Vue.component('tainacan-filter-taginput', FilterTaginput);
|
||||
Vue.component('tainacan-filter-category-checkbox', FilterCategoryCheckbox);
|
||||
Vue.component('tainacan-filter-category-taginput', FilterCategoryTaginput);
|
||||
Vue.component('tainacan-filter-category-selectbox', FilterCategorySelectbox);
|
||||
Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox);
|
||||
Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput);
|
||||
Vue.component('tainacan-filter-taxonomy-selectbox', FilterTaxonomySelectbox);
|
||||
|
||||
/* Others */
|
||||
Vue.component('help-button', HelpButton);
|
||||
|
|
|
@ -9,15 +9,15 @@ import ItemsPage from '../pages/lists/items-page.vue'
|
|||
import ItemPage from '../pages/singles/item-page.vue'
|
||||
import MetadataPage from '../pages/lists/metadata-page.vue'
|
||||
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 CategoriesPage from '../pages/lists/taxonomies-page.vue'
|
||||
import TaxonomyPage from '../pages/singles/taxonomy-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'
|
||||
import ItemEditionForm from '../components/edition/item-edition-form.vue'
|
||||
import CategoryEditionForm from '../components/edition/category-edition-form.vue'
|
||||
import TaxonomyEditionForm from '../components/edition/taxonomy-edition-form.vue'
|
||||
|
||||
// Listing components
|
||||
import FiltersList from '../components/lists/filters-list.vue'
|
||||
|
@ -58,10 +58,10 @@ const routes = [
|
|||
|
||||
{ path: '/metadata', name: 'MetadataPage', component: MetadataPage, meta: {title: i18nGet('title_repository_metadata_page'), icon: 'format-list-checks'} },
|
||||
|
||||
{ path: '/taxonomies', name: 'CategoriesPage', component: CategoriesPage, meta: {title: i18nGet('title_categories_page'), icon: 'shape'} },
|
||||
{ path: '/taxonomies/new', name: 'CategoryCreationForm', component: CategoryEditionForm, meta: {title: i18nGet('title_create_category_page'), icon: 'shape'} },
|
||||
{ path: '/taxonomies/:categoryId/edit', name: 'CategoryEditionForm', component: CategoryEditionForm, meta: {title: i18nGet('title_category_edition_page'), icon: 'shape'} },
|
||||
{ path: '/taxonomies/:categoryId', name: 'CategoryPage', component: CategoryPage, meta: {title: i18nGet('title_category_page'), icon: 'shape'} },
|
||||
{ path: '/taxonomies', name: 'CategoriesPage', component: CategoriesPage, meta: {title: i18nGet('title_taxonomies_page'), icon: 'shape'} },
|
||||
{ path: '/taxonomies/new', name: 'TaxonomyCreationForm', component: TaxonomyEditionForm, meta: {title: i18nGet('title_create_taxonomy_page'), icon: 'shape'} },
|
||||
{ path: '/taxonomies/:taxonomyId/edit', name: 'TaxonomyEditionForm', component: TaxonomyEditionForm, meta: {title: i18nGet('title_taxonomy_edition_page'), icon: 'shape'} },
|
||||
{ path: '/taxonomies/:taxonomyId', name: 'TaxonomyPage', component: TaxonomyPage, meta: {title: i18nGet('title_taxonomy_page'), icon: 'shape'} },
|
||||
|
||||
{ path: '/events', name: 'EventsPage', component: EventsPage, meta: {title: i18nGet('title_repository_events_page'), icon: 'flash'} },
|
||||
{ path: '/events/:eventId', name: 'EventPage', component: EventPage, meta: {title: i18nGet('title_event_page'), icon: 'flash'} },
|
||||
|
|
|
@ -10,10 +10,10 @@ import Selectbox from '../../classes/metadata-types/selectbox/Selectbox.vue';
|
|||
import Numeric from '../../classes/metadata-types/numeric/Numeric.vue';
|
||||
import Date from '../../classes/metadata-types/date/Date.vue';
|
||||
import Relationship from '../../classes/metadata-types/relationship/Relationship.vue';
|
||||
import Category from '../../classes/metadata-types/category/Category.vue';
|
||||
import Taxonomy from '../../classes/metadata-types/taxonomy/Taxonomy.vue';
|
||||
|
||||
import FormRelationship from '../../classes/metadata-types/relationship/FormRelationship.vue';
|
||||
import FormCategory from '../../classes/metadata-types/category/FormCategory.vue';
|
||||
import FormTaxonomy from '../../classes/metadata-types/taxonomy/FormTaxonomy.vue';
|
||||
import FormSelectbox from '../../classes/metadata-types/selectbox/FormSelectbox.vue';
|
||||
|
||||
import FilterCustomInterval from '../../classes/filter-types/custom-interval/CustomInterval.vue';
|
||||
|
@ -22,9 +22,9 @@ import FilterAutocomplete from '../../classes/filter-types/autocomplete/Autocomp
|
|||
import FilterCheckbox from '../../classes/filter-types/checkbox/Checkbox.vue';
|
||||
import FilterTaginput from '../../classes/filter-types/taginput/Taginput.vue';
|
||||
|
||||
import FilterCategoryCheckbox from '../../classes/filter-types/category/Checkbox.vue';
|
||||
import FilterCategoryTaginput from '../../classes/filter-types/category/Taginput.vue';
|
||||
import FilterCategorySelectbox from '../../classes/filter-types/category/Selectbox.vue';
|
||||
import FilterTaxonomyCheckbox from '../../classes/filter-types/taxonomy/Checkbox.vue';
|
||||
import FilterTaxonomyTaginput from '../../classes/filter-types/taxonomy/Taginput.vue';
|
||||
import FilterTaxonomySelectbox from '../../classes/filter-types/taxonomy/Selectbox.vue';
|
||||
|
||||
import TaincanFormItem from '../../classes/metadata-types/tainacan-form-item.vue';
|
||||
import TaincanFiltersList from '../../classes/filter-types/tainacan-filter-item.vue';
|
||||
|
@ -55,10 +55,10 @@ Vue.component('tainacan-selectbox', Selectbox);
|
|||
Vue.component('tainacan-numeric', Numeric);
|
||||
Vue.component('tainacan-date', Date);
|
||||
Vue.component('tainacan-relationship', Relationship);
|
||||
Vue.component('tainacan-category', Category);
|
||||
Vue.component('tainacan-taxonomy', Taxonomy);
|
||||
|
||||
Vue.component('tainacan-form-relationship', FormRelationship);
|
||||
Vue.component('tainacan-form-category', FormCategory);
|
||||
Vue.component('tainacan-form-taxonomy', FormTaxonomy);
|
||||
Vue.component('tainacan-form-selectbox', FormSelectbox);
|
||||
Vue.component('tainacan-form-item', TaincanFormItem);
|
||||
Vue.component('tainacan-filter-item', TaincanFiltersList);
|
||||
|
@ -69,9 +69,9 @@ Vue.component('tainacan-filter-selectbox', FilterSelectbox);
|
|||
Vue.component('tainacan-filter-autocomplete', FilterAutocomplete);
|
||||
Vue.component('tainacan-filter-checkbox', FilterCheckbox);
|
||||
Vue.component('tainacan-filter-taginput', FilterTaginput);
|
||||
Vue.component('tainacan-filter-category-checkbox', FilterCategoryCheckbox);
|
||||
Vue.component('tainacan-filter-category-taginput', FilterCategoryTaginput);
|
||||
Vue.component('tainacan-filter-category-selectbox', FilterCategorySelectbox);
|
||||
Vue.component('tainacan-filter-taxonomy-checkbox', FilterTaxonomyCheckbox);
|
||||
Vue.component('tainacan-filter-taxonomy-taginput', FilterTaxonomyTaginput);
|
||||
Vue.component('tainacan-filter-taxonomy-selectbox', FilterTaxonomySelectbox);
|
||||
|
||||
/* Others */
|
||||
Vue.component('help-button', HelpButton);
|
||||
|
|
|
@ -64,7 +64,7 @@ I18NPlugin.install = function (Vue, options = {}) {
|
|||
return (string != undefined && string != null && string != '' ) ? string : "Invalid i18n key: " + tainacan_plugin.i18n[key];
|
||||
},
|
||||
getFrom(entity, key) {
|
||||
if (entity == 'categories') // Temporary hack, while we decide this terminology...
|
||||
if (entity == 'taxonomies') // Temporary hack, while we decide this terminology...
|
||||
entity = 'taxonomies'
|
||||
if (tainacan_plugin.i18n['entities_labels'][entity] == undefined)
|
||||
return 'Invalid i18n entity: ' + entity;
|
||||
|
@ -72,7 +72,7 @@ I18NPlugin.install = function (Vue, options = {}) {
|
|||
return (string != undefined && string != null && string != '' ) ? string : "Invalid i18n key: " + key;
|
||||
},
|
||||
getHelperTitle(entity, key) {
|
||||
if (entity == 'categories') // Temporary hack, while we decide this terminology...
|
||||
if (entity == 'taxonomies') // Temporary hack, while we decide this terminology...
|
||||
entity = 'taxonomies'
|
||||
if (tainacan_plugin.i18n['helpers_label'][entity] == undefined)
|
||||
return 'Invalid i18n entity: ' + entity;
|
||||
|
@ -82,7 +82,7 @@ I18NPlugin.install = function (Vue, options = {}) {
|
|||
return (string != undefined && string != null && string != '' ) ? string : "Invalid i18n helper object.";
|
||||
},
|
||||
getHelperMessage(entity, key) {
|
||||
if (entity == 'categories') // Temporary hack, while we decide this terminology...
|
||||
if (entity == 'taxonomies') // Temporary hack, while we decide this terminology...
|
||||
entity = 'taxonomies'
|
||||
if (tainacan_plugin.i18n['helpers_label'][entity] == undefined)
|
||||
return 'Invalid i18n entity: ' + entity;
|
||||
|
@ -197,8 +197,8 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
|
|||
getCategoriesPath(query) {
|
||||
return '/taxonomies/?' + qs.stringify(query);
|
||||
},
|
||||
getCategoryTermsPath(categoryId, query) {
|
||||
return '/categoryId/' + categoryId + '/terms/?' + qs.stringify(query);
|
||||
getTaxonomyTermsPath(taxonomyId, query) {
|
||||
return '/taxonomyId/' + taxonomyId + '/terms/?' + qs.stringify(query);
|
||||
},
|
||||
getFiltersPath(query) {
|
||||
return '/filters/?' + qs.stringify(query);
|
||||
|
@ -219,11 +219,11 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
|
|||
getFilterPath(id) {
|
||||
return '/filters/' + id;
|
||||
},
|
||||
getCategoryPath(id) {
|
||||
getTaxonomyPath(id) {
|
||||
return '/taxonomies/' + id;
|
||||
},
|
||||
getTermPath(categoryId, termId) {
|
||||
return '/taxonomies/' + categoryId + '/terms/' + termId;
|
||||
getTermPath(taxonomyId, termId) {
|
||||
return '/taxonomies/' + taxonomyId + '/terms/' + termId;
|
||||
},
|
||||
getEventPath(id) {
|
||||
return '/events/' + id;
|
||||
|
@ -250,11 +250,11 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
|
|||
getNewFilterPath() {
|
||||
return '/filters/new';
|
||||
},
|
||||
getNewCategoryPath() {
|
||||
getNewTaxonomyPath() {
|
||||
return '/taxonomies/new';
|
||||
},
|
||||
getNewTermPath(categoryId) {
|
||||
return '/taxonomies/' + categoryId + '/terms/new';
|
||||
getNewTermPath(taxonomyId) {
|
||||
return '/taxonomies/' + taxonomyId + '/terms/new';
|
||||
},
|
||||
getNewEventPath() {
|
||||
return '/events/new';
|
||||
|
@ -269,11 +269,11 @@ RouterHelperPlugin.install = function (Vue, options = {}) {
|
|||
getFilterEditPath(id) {
|
||||
return '/filters/' + id + '/edit';
|
||||
},
|
||||
getCategoryEditPath(id) {
|
||||
getTaxonomyEditPath(id) {
|
||||
return '/taxonomies/' + id + '/edit';
|
||||
},
|
||||
getTermEditPath(categoryId, termId) {
|
||||
return '/taxonomies/' + categoryId + '/terms/' + termId + '/edit';
|
||||
getTermEditPath(taxonomyId, termId) {
|
||||
return '/taxonomies/' + taxonomyId + '/terms/' + termId + '/edit';
|
||||
},
|
||||
getEventEditPath(id) {
|
||||
return '/events/' + id + '/edit';
|
||||
|
|
|
@ -1,236 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="primary-page page-container">
|
||||
<tainacan-title />
|
||||
<div
|
||||
class="sub-header"
|
||||
v-if="$userCaps.hasCapability('edit_tainacan-taxonomies')">
|
||||
<div class="header-item">
|
||||
<router-link
|
||||
id="button-create-category"
|
||||
tag="button"
|
||||
class="button is-secondary"
|
||||
:to="{ path: $routerHelper.getNewCategoryPath() }">
|
||||
{{ $i18n.getFrom('taxonomies', 'new_item') }}
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="above-subheader">
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li
|
||||
@click="onChangeTab('')"
|
||||
:class="{ 'is-active': status == undefined || status == ''}"><a>{{ $i18n.get('label_all_items') }}</a></li>
|
||||
<li
|
||||
@click="onChangeTab('draft')"
|
||||
:class="{ 'is-active': status == 'draft'}"><a>{{ $i18n.get('label_draft_items') }}</a></li>
|
||||
<li
|
||||
@click="onChangeTab('trash')"
|
||||
:class="{ 'is-active': status == 'trash'}"><a>{{ $i18n.get('label_trash_items') }}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<categories-list
|
||||
:is-loading="isLoading"
|
||||
:total-categories="totalCategories"
|
||||
:page="page"
|
||||
:categories-per-page="taxonomiesPerPage"
|
||||
:categories="categories"/>
|
||||
|
||||
<!-- Empty state image -->
|
||||
<div v-if="totalCategories <= 0 && !isLoading">
|
||||
<section class="section">
|
||||
<div class="content has-text-grey has-text-centered">
|
||||
<p>
|
||||
<b-icon
|
||||
icon="inbox"
|
||||
size="is-large"/>
|
||||
</p>
|
||||
<p v-if="status == undefined || status == ''">{{ $i18n.get('info_no_category_created') }}</p>
|
||||
<p v-if="status == 'draft'">{{ $i18n.get('info_no_category_draft') }}</p>
|
||||
<p v-if="status == 'trash'">{{ $i18n.get('info_no_category_trash') }}</p>
|
||||
<router-link
|
||||
v-if="status == undefined || status == ''"
|
||||
id="button-create-category"
|
||||
tag="button"
|
||||
class="button is-primary"
|
||||
:to="{ path: $routerHelper.getNewCategoryPath() }">
|
||||
{{ $i18n.getFrom('categories', 'new_item') }}
|
||||
</router-link>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<!-- Footer -->
|
||||
<div
|
||||
class="pagination-area"
|
||||
v-if="totalCategories > 0">
|
||||
<div class="shown-items">
|
||||
{{
|
||||
$i18n.get('info_showing_categories') +
|
||||
(taxonomiesPerPage * (page - 1) + 1) +
|
||||
$i18n.get('info_to') +
|
||||
getLastCategoryNumber() +
|
||||
$i18n.get('info_of') + totalCategories + '.'
|
||||
}}
|
||||
</div>
|
||||
<div class="items-per-page">
|
||||
<b-field
|
||||
horizontal
|
||||
:label="$i18n.get('label_categories_per_page')">
|
||||
<b-select
|
||||
:value="taxonomiesPerPage"
|
||||
@input="onChangeCategoriesPerPage"
|
||||
:disabled="categories.length <= 0">
|
||||
<option value="12">12</option>
|
||||
<option value="24">24</option>
|
||||
<option value="48">48</option>
|
||||
<option value="96">96</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
</div>
|
||||
<div class="pagination">
|
||||
<b-pagination
|
||||
@change="onPageChange"
|
||||
:total="totalCategories"
|
||||
:current.sync="page"
|
||||
order="is-centered"
|
||||
size="is-small"
|
||||
:per-page="taxonomiesPerPage"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CategoriesList from "../../components/lists/categories-list.vue";
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
//import moment from 'moment'
|
||||
|
||||
export default {
|
||||
name: 'CategoriesPage',
|
||||
data(){
|
||||
return {
|
||||
isLoading: false,
|
||||
totalCategories: 0,
|
||||
page: 1,
|
||||
taxonomiesPerPage: 12,
|
||||
status: ''
|
||||
}
|
||||
},
|
||||
components: {
|
||||
CategoriesList
|
||||
},
|
||||
methods: {
|
||||
...mapActions('category', [
|
||||
'fetchCategories',
|
||||
]),
|
||||
...mapGetters('category', [
|
||||
'getCategories'
|
||||
]),
|
||||
onChangeTab(status) {
|
||||
this.status = status;
|
||||
this.loadCategories();
|
||||
},
|
||||
onChangeCategoriesPerPage(value) {
|
||||
this.taxonomiesPerPage = value;
|
||||
this.$userPrefs.set('taxonomies_per_page', value)
|
||||
.then((newValue) => {
|
||||
this.taxonomiesPerPage = newValue;
|
||||
})
|
||||
.catch(() => {
|
||||
this.$console.log("Error settings user prefs for taxonomies per page")
|
||||
});
|
||||
this.loadCategories();
|
||||
},
|
||||
onPageChange(page) {
|
||||
this.page = page;
|
||||
this.loadCategories();
|
||||
},
|
||||
loadCategories() {
|
||||
this.isLoading = true;
|
||||
|
||||
this.fetchCategories({ 'page': this.page, 'taxonomiesPerPage': this.taxonomiesPerPage, 'status': this.status })
|
||||
.then((res) => {
|
||||
this.isLoading = false;
|
||||
this.totalCategories = res.total;
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoading = false;
|
||||
});
|
||||
},
|
||||
getLastCategoryNumber() {
|
||||
let last = (Number(this.taxonomiesPerPage * (this.page - 1)) + Number(this.taxonomiesPerPage));
|
||||
return last > this.totalCategories ? this.totalCategories : last;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
categories(){
|
||||
return this.getCategories();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.taxonomiesPerPage = this.$userPrefs.get('taxonomies_per_page');
|
||||
},
|
||||
mounted(){
|
||||
this.$userPrefs.fetch('taxonomies_per_page')
|
||||
.then((value) => {
|
||||
if (this.taxonomiesPerPage != value) {
|
||||
this.taxonomiesPerPage = value;
|
||||
this.loadCategories;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.$userPrefs.set('taxonomies_per_page', 12);
|
||||
});
|
||||
this.loadCategories();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '../../scss/_variables.scss';
|
||||
|
||||
.sub-header {
|
||||
max-height: $subheader-height;
|
||||
height: $subheader-height;
|
||||
margin-left: -$page-side-padding;
|
||||
margin-right: -$page-side-padding;
|
||||
margin-top: -$page-top-padding;
|
||||
padding-top: $page-small-top-padding;
|
||||
padding-left: $page-side-padding;
|
||||
padding-right: $page-side-padding;
|
||||
border-bottom: 1px solid #ddd;
|
||||
|
||||
.header-item {
|
||||
display: inline-block;
|
||||
padding-right: 8em;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 769px) {
|
||||
height: 60px;
|
||||
margin-top: -0.5em;
|
||||
padding-top: 0.9em;
|
||||
|
||||
.header-item {
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
}
|
||||
}
|
||||
.tabs {
|
||||
padding-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
padding-left: $page-side-padding;
|
||||
padding-right: $page-side-padding;
|
||||
}
|
||||
.above-subheader {
|
||||
margin-bottom: 0;
|
||||
margin-top: 0;
|
||||
height: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
<template>
|
||||
<div class="columns is-fullheight">
|
||||
<div class="page-container primary-page">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<p class="title">
|
||||
{{ category.name }}
|
||||
</p>
|
||||
<p class="subtitle">
|
||||
{{ category.description }}
|
||||
</p>
|
||||
</div>
|
||||
<footer class="card-footer">
|
||||
<router-link
|
||||
class="card-footer-item"
|
||||
:to="{ path: $routerHelper.getCategoryEditPath(categoryId)}">
|
||||
{{ $i18n.getFrom('taxonomies','edit_item') }}
|
||||
</router-link>
|
||||
<a class="card-footer-item">
|
||||
Edit terms
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
|
||||
export default {
|
||||
name: 'CategoryPage',
|
||||
data(){
|
||||
return {
|
||||
categoryId: Number,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('category', [
|
||||
'fetchCategory'
|
||||
]),
|
||||
...mapGetters('category', [
|
||||
'getCategory'
|
||||
])
|
||||
},
|
||||
computed: {
|
||||
category(){
|
||||
return this.getCategory();
|
||||
}
|
||||
},
|
||||
created(){
|
||||
this.categoryId = parseInt(this.$route.params.categoryId);
|
||||
|
||||
this.fetchCategory(this.categoryId);
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -68,7 +68,7 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'title_items_page' => __( 'Items', 'tainacan' ),
|
||||
'title_repository_metadata_page' => __( 'Repository Metadata', 'tainacan' ),
|
||||
'title_repository_filters_page' => __( 'Repository Filters', 'tainacan' ),
|
||||
'title_categories_page' => __( 'Categories Page', 'tainacan' ),
|
||||
'title_taxonomies_page' => __( 'Taxonomies Page', 'tainacan' ),
|
||||
'title_terms_page' => __( 'Terms', 'tainacan' ),
|
||||
'title_repository_events_page' => __( 'Repository Events', 'tainacan' ),
|
||||
'title_collection_page' => __( 'Collection', 'tainacan' ),
|
||||
|
@ -76,16 +76,16 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'title_metadatum_page' => __( 'Metadata', 'tainacan' ),
|
||||
'title_collection_events' => __( 'Collection Events', 'tainacan' ),
|
||||
'title_filter_page' => __( 'Filter', 'tainacan' ),
|
||||
'title_category_page' => __( 'Taxonomy', 'tainacan' ),
|
||||
'title_taxonomy_page' => __( 'Taxonomy', 'tainacan' ),
|
||||
'title_term_page' => __( 'Term', 'tainacan' ),
|
||||
'title_event_page' => __( 'Event', 'tainacan' ),
|
||||
'title_create_collection' => __( 'Collection Creation', 'tainacan' ),
|
||||
'title_create_category_page' => __( 'Taxonomy Creation', 'tainacan' ),
|
||||
'title_create_taxonomy_page' => __( 'Taxonomy Creation', 'tainacan' ),
|
||||
'title_create_item_collection' => __( 'Create Item on Collection', 'tainacan' ),
|
||||
'title_create_filter' => __( 'Filter Creation', 'tainacan' ),
|
||||
'title_collection_settings' => __( 'Settings of Collection', 'tainacan' ),
|
||||
'title_edit_item' => __( 'Edit Item', 'tainacan' ),
|
||||
'title_category_edition_page' => __( 'Taxonomy Edition', 'tainacan' ),
|
||||
'title_taxonomy_edition_page' => __( 'Taxonomy Edition', 'tainacan' ),
|
||||
'title_filter_edition' => __( 'Filter Edition', 'tainacan' ),
|
||||
'title_metadatum_edition' => __( 'Metadata Edition', 'tainacan' ),
|
||||
'title_collection_metadata_edition' => __( 'Edit Metadata of', 'tainacan' ),
|
||||
|
@ -121,7 +121,7 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'label_choose_thumb' => __( 'Choose Thumbnail', 'tainacan' ),
|
||||
'label_button_delete_thumb' => __( 'Button Delete Thumbnail', 'tainacan' ),
|
||||
'label_collections_per_page' => __( 'Collections per Page:', 'tainacan' ),
|
||||
'label_categories_per_page' => __( 'Categories per Page:', 'tainacan' ),
|
||||
'label_taxonomies_per_page' => __( 'Taxonomies per Page:', 'tainacan' ),
|
||||
'label_events_per_page' => __( 'Events per Page:', 'tainacan' ),
|
||||
'label_items_per_page' => __( 'Items per Page:', 'tainacan' ),
|
||||
'label_active_metadata' => __( 'Active Metadata', 'tainacan' ),
|
||||
|
@ -143,9 +143,9 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'label_collection_related' => __( 'Collection Related', 'tainacan' ),
|
||||
'label_metadata_for_search' => __( 'Metadata for search', 'tainacan' ),
|
||||
'label_allow_repeated_items' => __( 'Allow repeated items', 'tainacan' ),
|
||||
'label_select_category' => __( 'Select taxonomy', 'tainacan' ),
|
||||
'label_select_category_input_type' => __( 'Input type', 'tainacan' ),
|
||||
'label_category_allow_new_terms' => __( 'Allow new terms', 'tainacan' ),
|
||||
'label_select_taxonomy' => __( 'Select taxonomy', 'tainacan' ),
|
||||
'label_select_taxonomy_input_type' => __( 'Input type', 'tainacan' ),
|
||||
'label_taxonomy_allow_new_terms' => __( 'Allow new terms', 'tainacan' ),
|
||||
'label_selectbox_init' => __( 'Select', 'tainacan' ),
|
||||
'label_options' => __( 'Insert options', 'tainacan' ),
|
||||
'label_attachments' => __( 'Attachments', 'tainacan' ),
|
||||
|
@ -160,7 +160,7 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'label_parent_term' => __( 'Parent Term', 'tainacan' ),
|
||||
'label_new_term' => __( 'New Term', 'tainacan' ),
|
||||
'label_new_child' => __( 'New Child', 'tainacan' ),
|
||||
'label_category_terms' => __( 'Taxonomy Terms', 'tainacan' ),
|
||||
'label_taxonomy_terms' => __( 'Taxonomy Terms', 'tainacan' ),
|
||||
'label_no_parent_term' => __( 'No parent term', 'tainacan' ),
|
||||
'label_term_without_name' => __( 'Term without name', 'tainacan' ),
|
||||
'label_inherited' => __( 'Inherited', 'tainacan' ),
|
||||
|
@ -193,12 +193,12 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'label_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||
'label_edit_selected_collections' => __( 'Edit selected collections', 'tainacan' ),
|
||||
'label_delete_selected_items' => __( 'Delete selected items', 'tainacan' ),
|
||||
'label_delete_selected_categories' => __( 'Delete selected categories', 'tainacan' ),
|
||||
'label_delete_selected_taxonomies' => __( 'Delete selected taxonomies', 'tainacan' ),
|
||||
'label_edit_selected_items' => __( 'Edit selected items', 'tainacan' ),
|
||||
'label_edit_selected_categories' => __( 'Edit selected categories', 'tainacan' ),
|
||||
'label_edit_selected_taxonomies' => __( 'Edit selected taxonomies', 'tainacan' ),
|
||||
'label_select_all_collections_page' => __( 'Select all collections on page', 'tainacan' ),
|
||||
'label_select_all_items_page' => __( 'Select all items on page', 'tainacan' ),
|
||||
'label_select_all_categories_page' => __( 'Select all categories on page', 'tainacan' ),
|
||||
'label_select_all_taxonomies_page' => __( 'Select all taxonomies on page', 'tainacan' ),
|
||||
'label_edit_attachments' => __( 'Edit attachments', 'tainacan' ),
|
||||
'label_blank_collection' => __( 'Blank collection', 'tainacan' ),
|
||||
'label_dublin_core' => __( 'Dublin Core', 'tainacan' ),
|
||||
|
@ -218,7 +218,7 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||
'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ),
|
||||
'instruction_delete_selected_categories' => __( 'Delete selected categories', 'tainacan' ),
|
||||
'instruction_delete_selected_taxonomies' => __( 'Delete selected taxonomies', 'tainacan' ),
|
||||
'instruction_image_upload_box' => __( 'Drop an image here or click to upload.', 'tainacan' ),
|
||||
'instruction_select_a_status' => __( 'Select a status:', 'tainacan' ),
|
||||
'instruction_select_a_filter_type' => __( 'Select a filter type:', 'tainacan' ),
|
||||
|
@ -243,9 +243,9 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'info_no_collection_created' => __( 'No collection was created in this repository.', 'tainacan' ),
|
||||
'info_no_collection_draft' => __( 'No draft collection found.', 'tainacan' ),
|
||||
'info_no_collection_trash' => __( 'No collection on trash.', 'tainacan' ),
|
||||
'info_no_category_draft' => __( 'No draft category found.', 'tainacan' ),
|
||||
'info_no_category_trash' => __( 'No category on trash.', 'tainacan' ),
|
||||
'info_no_category_created' => __( 'No taxonomy was created in this repository.', 'tainacan' ),
|
||||
'info_no_taxonomy_draft' => __( 'No draft taxonomy found.', 'tainacan' ),
|
||||
'info_no_taxonomy_trash' => __( 'No taxonomy on trash.', 'tainacan' ),
|
||||
'info_no_taxonomy_created' => __( 'No taxonomy was created in this repository.', 'tainacan' ),
|
||||
'info_no_item_created' => __( 'No item was created in this collection.', 'tainacan' ),
|
||||
'info_no_item_draft' => __( 'No draft item found.', 'tainacan' ),
|
||||
'info_no_item_trash' => __( 'No item on trash.', 'tainacan' ),
|
||||
|
@ -255,25 +255,25 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'info_item_not_saved' => __( 'Warning: Item not saved.', 'tainacan' ),
|
||||
'info_no_moderator_on_collection' => __( "This collection doesn't have any moderator yet.", 'tainacan' ),
|
||||
'info_error_deleting_collection' => __( 'Error on deleting collection.', 'tainacan' ),
|
||||
'info_error_deleting_category' => __( 'Error on deleting taxonomy', 'tainacan' ),
|
||||
'info_error_deleting_taxonomy' => __( 'Error on deleting taxonomy', 'tainacan' ),
|
||||
'info_collection_deleted' => __( 'Collection deleted.', 'tainacan' ),
|
||||
'info_item_deleted' => __( 'Item deleted.', 'tainacan' ),
|
||||
'info_category_deleted' => __( 'Taxonomy deleted', 'tainacan' ),
|
||||
'info_taxonomy_deleted' => __( 'Taxonomy deleted', 'tainacan' ),
|
||||
'info_warning_collection_delete' => __( 'Do you really want to permanently delete this collection?', 'tainacan' ),
|
||||
'info_warning_collection_trash' => __( 'Do you really want to trash this collection?', 'tainacan' ),
|
||||
'info_warning_item_delete' => __( 'Do you really want to permanently delete this item?', 'tainacan' ),
|
||||
'info_warning_item_trash' => __( 'Do you really want to trash this item?', 'tainacan' ),
|
||||
'info_warning_category_delete' => __( 'Do you really want to delete this taxonomy?', 'tainacan' ),
|
||||
'info_warning_taxonomy_delete' => __( 'Do you really want to delete this taxonomy?', 'tainacan' ),
|
||||
'info_warning_selected_collections_delete' => __( 'Do you really want to permanently delete the selected collections?', 'tainacan' ),
|
||||
'info_warning_selected_collections_trash' => __( 'Do you really want to trash the selected collections?', 'tainacan' ),
|
||||
'info_warning_selected_items_delete' => __( 'Do you really want to permanently delete the selected items?', 'tainacan' ),
|
||||
'info_warning_selected_items_trash' => __( 'Do you really want to trash the selected items?', 'tainacan' ),
|
||||
'info_warning_selected_categories_delete' => __( 'Do you really want to delete the selected categories?', 'tainacan' ),
|
||||
'info_warning_selected_taxonomies_delete' => __( 'Do you really want to delete the selected taxonomies?', 'tainacan' ),
|
||||
'info_warning_collection_related' => __( 'The metadata Collection related is required', 'tainacan' ),
|
||||
'info_warning_no_metadata_found' => __( 'No metadata found in this collection', 'tainacan' ),
|
||||
'info_showing_items' => __( 'Showing items ', 'tainacan' ),
|
||||
'info_showing_collections' => __( 'Showing collections ', 'tainacan' ),
|
||||
'info_showing_categories' => __( 'Showing categories ', 'tainacan' ),
|
||||
'info_showing_taxonomies' => __( 'Showing taxonomies ', 'tainacan' ),
|
||||
'info_showing_events' => __( 'Showing events ', 'tainacan' ),
|
||||
'info_to' => __( ' to ', 'tainacan' ),
|
||||
'info_of' => __( ' of ', 'tainacan' ),
|
||||
|
@ -285,7 +285,7 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'info_warning_metadata_not_saved' => __( 'Are you sure? There are metadata 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_category_not_saved' => __( 'Are you sure? The metadata is not saved, changes will be lost.', 'tainacan' ),
|
||||
'info_warning_taxonomy_not_saved' => __( 'Are you sure? The metadata 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_no_events' => __( 'No events', 'tainacan' ),
|
||||
|
@ -311,7 +311,7 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'tainacan-numeric' => __( 'Numeric', 'tainacan' ),
|
||||
'tainacan-selectbox' => __( 'Select box', 'tainacan' ),
|
||||
'tainacan-relationship' => __( 'Relationship', 'tainacan' ),
|
||||
'tainacan-category' => __( 'Taxonomy', 'tainacan' ),
|
||||
'tainacan-taxonomy' => __( 'Taxonomy', 'tainacan' ),
|
||||
|
||||
// Tainacan Filter Types
|
||||
'tainacan-filter-custom-interval' => __( 'Custom Interval', 'tainacan' ),
|
||||
|
@ -319,8 +319,8 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'tainacan-filter-autocomplete' => __( 'Autocomplete', 'tainacan' ),
|
||||
'tainacan-filter-taginput' => __( 'Tag Input', 'tainacan' ),
|
||||
'tainacan-filter-checkbox' => __( 'Check Box', 'tainacan' ),
|
||||
'tainacan-filter-category-taginput' => __( 'Taxonomy Tag Input', 'tainacan' ),
|
||||
'tainacan-filter-category-checkbox' => __( 'Taxonomy Check Box', 'tainacan' ),
|
||||
'tainacan-filter-category-selectbox' => __( 'Taxonomy Select Box', 'tainacan' )
|
||||
'tainacan-filter-taxonomy-taginput' => __( 'Taxonomy Tag Input', 'tainacan' ),
|
||||
'tainacan-filter-taxonomy-checkbox' => __( 'Taxonomy Check Box', 'tainacan' ),
|
||||
'tainacan-filter-taxonomy-selectbox' => __( 'Taxonomy Select Box', 'tainacan' )
|
||||
]);
|
||||
?>
|
||||
|
|
|
@ -421,15 +421,15 @@ class Metadatum extends Entity {
|
|||
if (false === $is_valid)
|
||||
return false;
|
||||
|
||||
// You cant have a multiple metadatum inside a compound metadatum (except category)
|
||||
// You cant have a multiple metadatum inside a compound metadatum (except taxonomy)
|
||||
if ($this->get_parent() > 0) {
|
||||
if ( $this->is_multiple() && $this->get_metadata_type_object()->get_primitive_type() != 'term') {
|
||||
$this->add_error($this->get_id(), __('Compound metadata do not support metadata with multiple values (except categories)', 'tainacan'));
|
||||
$this->add_error($this->get_id(), __('Compound metadata do not support metadata with multiple values (except taxonomies)', 'tainacan'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// You cant have a category metadatum inside a multiple compound metadatum
|
||||
// You cant have a taxonomy metadatum inside a multiple compound metadatum
|
||||
if ( $this->get_parent() > 0 && $this->get_metadata_type_object()->get_primitive_type() == 'term' ) {
|
||||
$parent_metadatum = new \Tainacan\Entities\Metadatum($this->get_parent());
|
||||
if ( $parent_metadatum->is_multiple() ) {
|
||||
|
@ -442,7 +442,7 @@ class Metadatum extends Entity {
|
|||
$children = $Tainacan_Metadata->fetch(
|
||||
[
|
||||
'parent' => $this->get_id(),
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Category',
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
|
||||
'post_status' => 'any'
|
||||
]
|
||||
, 'OBJECT');
|
||||
|
|
|
@ -1,129 +0,0 @@
|
|||
<template>
|
||||
<div class="block">
|
||||
<div
|
||||
v-for="(option,index) in getOptions(0)"
|
||||
:key="index"
|
||||
:value="index"
|
||||
class="control">
|
||||
<b-checkbox
|
||||
:style="{ paddingLeft: (option.level * 30) + 'px' }"
|
||||
v-model="selected"
|
||||
:native-value="option.id"
|
||||
>{{ option.name }}</b-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { tainacan as axios } from '../../../js/axios/axios';
|
||||
|
||||
export default {
|
||||
created(){
|
||||
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
|
||||
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id ;
|
||||
this.type = ( this.filter_type ) ? this.filter_type : this.filter.metadatum.metadata_type;
|
||||
this.loadOptions();
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
isLoading: false,
|
||||
options: [],
|
||||
type: '',
|
||||
collection: '',
|
||||
metadatum: '',
|
||||
selected: [],
|
||||
taxonomy: ''
|
||||
}
|
||||
},
|
||||
props: {
|
||||
filter: {
|
||||
type: Object // concentrate all attributes metadatum id and type
|
||||
},
|
||||
metadatum_id: [Number], // not required, but overrides the filter metadatum id if is set
|
||||
collection_id: [Number], // not required, but overrides the filter metadatum id if is set
|
||||
filter_type: [String], // not required, but overrides the filter metadatum type if is set
|
||||
id: '',
|
||||
query: {
|
||||
type: Object // concentrate all attributes metadatum id and type
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
selected: function(val){
|
||||
this.selected = val;
|
||||
this.onSelect();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getValuesCategory( taxonomy ){
|
||||
return axios.get('/taxonomy/' + taxonomy + '/terms?hideempty=0&order=asc' ).then( res => {
|
||||
for (let item of res.data) {
|
||||
this.taxonomy = item.taxonomy;
|
||||
this.options.push(item);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
loadOptions(){
|
||||
let promise = null;
|
||||
this.isLoading = true;
|
||||
|
||||
axios.get('/collection/'+ this.collection +'/metadata/' + this.metadatum)
|
||||
.then( res => {
|
||||
let metadatum = res.data;
|
||||
promise = this.getValuesCategory( metadatum.metadata_type_options.taxonomy_id );
|
||||
|
||||
promise.then( () => {
|
||||
this.isLoading = false;
|
||||
this.selectedValues()
|
||||
})
|
||||
.catch( error => {
|
||||
this.$console.log('error select', error );
|
||||
this.isLoading = false;
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
getOptions( parent, level = 0 ){ // retrieve only ids
|
||||
let result = [];
|
||||
if ( this.options ){
|
||||
for( let term of this.options ){
|
||||
if( term.parent == parent ){
|
||||
term['level'] = level;
|
||||
result.push( term );
|
||||
const levelTerm = level + 1;
|
||||
const children = this.getOptions( term.id, levelTerm);
|
||||
result = result.concat( children );
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
selectedValues(){
|
||||
if ( !this.query || !this.query.taxquery || !Array.isArray( this.query.taxquery ) )
|
||||
return false;
|
||||
|
||||
let index = this.query.taxquery.findIndex(newMetadatum => newMetadatum.taxonomy === this.taxonomy );
|
||||
if ( index >= 0){
|
||||
let metadata = this.query.taxquery[ index ];
|
||||
this.selected = metadata.terms;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
onSelect(){
|
||||
this.$emit('input', {
|
||||
filter: 'selectbox',
|
||||
taxonomy: this.taxonomy,
|
||||
compare: 'IN',
|
||||
metadatum_id: this.metadatum,
|
||||
collection_id: this.collection,
|
||||
terms: this.selected
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,131 +0,0 @@
|
|||
<template>
|
||||
<div class="block">
|
||||
<b-select
|
||||
:id = "id"
|
||||
:loading = "isLoading"
|
||||
v-model = "selected"
|
||||
@input = "onSelect()"
|
||||
size="is-small"
|
||||
expanded>
|
||||
<option value="">{{ $i18n.get('label_selectbox_init') }}...</option>
|
||||
<option
|
||||
v-for=" (option, index) in options"
|
||||
:key="index"
|
||||
:label="option.name"
|
||||
:value="option.id">{{ option.name }}</option>
|
||||
</b-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { tainacan as axios } from '../../../js/axios/axios';
|
||||
|
||||
export default {
|
||||
created(){
|
||||
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
|
||||
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id ;
|
||||
this.type = ( this.filter_type ) ? this.filter_type : this.filter.metadatum.metadata_type;
|
||||
this.loadOptions();
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
isLoading: false,
|
||||
options: [],
|
||||
collection: '',
|
||||
metadatum: '',
|
||||
selected: '',
|
||||
taxonomy: ''
|
||||
}
|
||||
},
|
||||
props: {
|
||||
filter: {
|
||||
type: Object // concentrate all attributes metadatum id and type
|
||||
},
|
||||
metadatum_id: [Number], // not required, but overrides the filter metadatum id if is set
|
||||
collection_id: [Number], // not required, but overrides the filter metadatum id if is set
|
||||
filter_type: [String], // not required, but overrides the filter metadatum type if is set
|
||||
id: '',
|
||||
query: {
|
||||
type: Object // concentrate all attributes metadatum id and type
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
selected: function(val){
|
||||
this.selected = val;
|
||||
this.onSelect();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getValuesCategory( taxonomy ){
|
||||
return axios.get('/taxonomy/' + taxonomy + '/terms?hideempty=0' ).then( res => {
|
||||
for (let item of res.data) {
|
||||
this.taxonomy = item.taxonomy;
|
||||
this.options.push(item);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
loadOptions(){
|
||||
let promise = null;
|
||||
this.isLoading = true;
|
||||
|
||||
axios.get('/collection/'+ this.collection +'/metadata/' + this.metadatum)
|
||||
.then( res => {
|
||||
let metadatum = res.data;
|
||||
promise = this.getValuesCategory( metadatum.metadata_type_options.taxonomy_id );
|
||||
|
||||
promise.then( () => {
|
||||
this.isLoading = false;
|
||||
this.selectedValues();
|
||||
})
|
||||
.catch( error => {
|
||||
this.$console.log('error select', error );
|
||||
this.isLoading = false;
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
getOptions( parent, level = 0 ){ // retrieve only ids
|
||||
let result = [];
|
||||
if ( this.options ){
|
||||
for( let term of this.options ){
|
||||
if( term.parent == parent ){
|
||||
term['level'] = level;
|
||||
result.push( term );
|
||||
const levelTerm = level + 1;
|
||||
const children = this.getOptions( term.id, levelTerm);
|
||||
result = result.concat( children );
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
selectedValues(){
|
||||
if ( !this.query || !this.query.taxquery || !Array.isArray( this.query.taxquery ) )
|
||||
return false;
|
||||
|
||||
let index = this.query.taxquery.findIndex(newMetadatum => newMetadatum.taxonomy === this.taxonomy );
|
||||
if ( index >= 0){
|
||||
let metadata = this.query.taxquery[ index ];
|
||||
this.selected = metadata.terms;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
onSelect(){
|
||||
this.$emit('input', {
|
||||
filter: 'selectbox',
|
||||
compare: 'IN',
|
||||
taxonomy: this.taxonomy,
|
||||
metadatum_id: this.metadatum,
|
||||
collection_id: this.collection,
|
||||
terms: this.selected
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,142 +0,0 @@
|
|||
<template>
|
||||
<div class="block">
|
||||
<b-taginput
|
||||
size="is-small"
|
||||
v-model="selected"
|
||||
:data="options"
|
||||
:loading="isLoading"
|
||||
autocomplete
|
||||
field="label"
|
||||
attached
|
||||
:class="{'has-selected': selected != undefined && selected != []}"
|
||||
@typing="search" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { tainacan as axios } from '../../../js/axios/axios'
|
||||
|
||||
export default {
|
||||
created(){
|
||||
this.collection = ( this.collection_id ) ? this.collection_id : this.filter.collection_id;
|
||||
this.metadatum = ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum.metadatum_id ;
|
||||
this.type = ( this.filter_type ) ? this.filter_type : this.filter.metadatum.metadata_type;
|
||||
|
||||
let in_route = '/collection/' + this.collection + '/metadata/' + this.metadatum;
|
||||
|
||||
if(this.isRepositoryLevel || this.collection == 'filter_in_repository'){
|
||||
in_route = '/metadata/'+ this.metadatum;
|
||||
}
|
||||
|
||||
axios.get(in_route)
|
||||
.then( res => {
|
||||
let metadatum = res.data;
|
||||
this.selectedValues( metadatum.metadata_type_options.taxonomy_id );
|
||||
});
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
results:'',
|
||||
selected:[],
|
||||
options: [],
|
||||
isLoading: false,
|
||||
type: '',
|
||||
collection: '',
|
||||
metadatum: '',
|
||||
taxonomy: ''
|
||||
}
|
||||
},
|
||||
props: {
|
||||
filter: {
|
||||
type: Object // concentrate all attributes metadatum id and type
|
||||
},
|
||||
metadatum_id: [Number], // not required, but overrides the filter metadatum id if is set
|
||||
collection_id: [Number], // not required, but overrides the filter metadatum id if is set
|
||||
filter_type: [String], // not required, but overrides the filter metadatum type if is set
|
||||
id: '',
|
||||
query: {
|
||||
type: Object // concentrate all attributes metadatum id and type
|
||||
},
|
||||
isRepositoryLevel: Boolean,
|
||||
},
|
||||
watch: {
|
||||
selected( value ){
|
||||
this.selected = value;
|
||||
let values = [];
|
||||
if( this.selected.length > 0 ){
|
||||
for(let val of this.selected){
|
||||
values.push( val.value );
|
||||
}
|
||||
}
|
||||
this.$emit('input', {
|
||||
filter: 'taginput',
|
||||
compare: 'IN',
|
||||
taxonomy: this.taxonomy,
|
||||
metadatum_id: ( this.metadatum_id ) ? this.metadatum_id : this.filter.metadatum,
|
||||
collection_id: ( this.collection_id ) ? this.collection_id : this.filter.collection_id,
|
||||
terms: values
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
search( query ){
|
||||
let promise = null;
|
||||
this.options = [];
|
||||
const q = query;
|
||||
const endpoint = this.isRepositoryLevel ? '/metadata/' + this.metadatum : '/collection/'+ this.collection +'/metadata/' + this.metadatum;
|
||||
|
||||
axios.get(endpoint)
|
||||
.then( res => {
|
||||
let metadatum = res.data;
|
||||
promise = this.getValuesCategory( metadatum.metadata_type_options.taxonomy_id, q );
|
||||
this.isLoading = true;
|
||||
promise.then( () => {
|
||||
this.isLoading = false;
|
||||
})
|
||||
.catch( error => {
|
||||
this.$console.log('error select', error );
|
||||
this.isLoading = false;
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
getValuesCategory( taxonomy, query ){
|
||||
return axios.get('/taxonomy/' + taxonomy + '/terms?hideempty=0&order=asc' ).then( res => {
|
||||
for (let term of res.data) {
|
||||
if( term.name.toLowerCase().indexOf( query.toLowerCase() ) >= 0 ){
|
||||
this.taxonomy = term.taxonomy;
|
||||
this.options.push({label: term.name, value: term.id});
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
selectedValues( taxonomy ){
|
||||
if ( !this.query || !this.query.taxquery || !Array.isArray( this.query.taxquery ) )
|
||||
return false;
|
||||
|
||||
let index = this.query.taxquery.findIndex(newMetadatum => newMetadatum.taxonomy === this.taxonomy );
|
||||
if ( index >= 0){
|
||||
let metadata = this.query.taxquery[ index ];
|
||||
for ( let id of metadata.terms ){
|
||||
this.getTerm( taxonomy, id );
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
getTerm( taxonomy, id ){
|
||||
return axios.get('/taxonomy/' + taxonomy + '/terms/' + id + '?order=asc&hideempty=0' ).then( res => {
|
||||
this.$console.log(res);
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
namespace Tainacan\Filter_Types;
|
||||
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
*/
|
||||
class CategoryCheckbox extends Filter_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->set_supported_types(['term']);
|
||||
$this->set_component('tainacan-filter-category-checkbox');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filter
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function render( $filter ){
|
||||
return '<tainacan-filter-category-checkbox name="'.$filter->get_name().'"
|
||||
filter_type="'.$filter->get_metadatum()->get_metadata_type().'"
|
||||
collection_id="'.$filter->get_collection_id().'"
|
||||
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-checkbox>';
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
namespace Tainacan\Filter_Types;
|
||||
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
*/
|
||||
class CategorySelectbox extends Filter_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->set_supported_types(['term']);
|
||||
$this->set_component('tainacan-filter-category-selectbox');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filter
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function render( $filter ){
|
||||
return '<tainacan-filter-category-selectbox name="'.$filter->get_name().'"
|
||||
filter_type="'.$filter->get_metadatum()->get_metadata_type().'"
|
||||
collection_id="'.$filter->get_collection_id().'"
|
||||
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-selectbox>';
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
namespace Tainacan\Filter_Types;
|
||||
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class Taginput
|
||||
*/
|
||||
class CategoryTaginput extends Filter_Type {
|
||||
|
||||
function __construct(){
|
||||
$this->set_supported_types(['term']);
|
||||
$this->set_component('tainacan-filter-category-taginput');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filter
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function render( $filter ){
|
||||
return '<tainacan-filter-category-taginput name="'.$filter->get_name().'"
|
||||
filter_type="'.$filter->get_metadatum()->get_metadata_type().'"
|
||||
collection_id="'.$filter->get_collection_id().'"
|
||||
metadatum_id="'.$filter->get_metadatum()->get_id().'"></tainacan-filter-taginput>';
|
||||
}
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<span>
|
||||
<a
|
||||
class="button"
|
||||
@click="showForm = !showForm"><b-icon
|
||||
size="is-small"
|
||||
icon="plus"/> {{ $i18n.get('label_new_term') }}</a>
|
||||
</span>
|
||||
<div class="columns">
|
||||
<transition name="fade">
|
||||
|
||||
<section
|
||||
v-if="showForm"
|
||||
class="column is-one-third"
|
||||
style="padding-left: 0px;">
|
||||
|
||||
<b-field :label="$i18n.get('label_name')">
|
||||
<b-input
|
||||
:class="{'has-content': name != undefined && name != ''}"
|
||||
v-model="name"/>
|
||||
</b-field>
|
||||
|
||||
<b-field :label="$i18n.get('label_parent_term')">
|
||||
<b-select
|
||||
v-model="parent">
|
||||
<option
|
||||
:value="0"
|
||||
selected> ---{{ $i18n.get('label_parent_term') }}--- </option>
|
||||
<option
|
||||
v-for="(option,index) in options"
|
||||
:key="index"
|
||||
:value="option.id"
|
||||
v-html="setSpaces( option.level ) + option.name"/>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
<a
|
||||
class="button is-primary"
|
||||
@click="save">{{ $i18n.get('save') }}</a>
|
||||
</section>
|
||||
|
||||
</transition>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import { tainacan as axios } from '../../../js/axios/axios'
|
||||
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
name: '',
|
||||
parent: 0,
|
||||
showForm: false,
|
||||
metadatum_id: this.metadatum.metadatum.id
|
||||
}
|
||||
},
|
||||
props: {
|
||||
id: String,
|
||||
item_id: [Number,String],
|
||||
metadatum: [Number,String],
|
||||
taxonomy_id: [Number,String],
|
||||
value:[ Array, Boolean, Number ],
|
||||
options: {
|
||||
type: Array
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setSpaces( level ){
|
||||
let result = '';
|
||||
let space = ' '
|
||||
|
||||
for(let i = 0;i < level; i++)
|
||||
result += space;
|
||||
|
||||
return result;
|
||||
},
|
||||
save(){
|
||||
if( this.name.trim() === ''){
|
||||
this.$toast.open({
|
||||
duration: 2000,
|
||||
message: this.$i18n.get('info_name_is_required'),
|
||||
position: 'is-bottom',
|
||||
type: 'is-danger'
|
||||
})
|
||||
} else {
|
||||
const instance = this;
|
||||
|
||||
axios.post(`/taxonomy/${this.taxonomy_id}/terms?hideempty=0&order=asc`, {
|
||||
name: this.name,
|
||||
parent: this.parent
|
||||
})
|
||||
.then( res => {
|
||||
instance.name = '';
|
||||
instance.parent = 0;
|
||||
|
||||
if( res.data && res.data.id || res.id ){
|
||||
let id = ( res.id ) ? res.id : res.data.id;
|
||||
let val = this.value;
|
||||
|
||||
if( !Array.isArray( val ) && this.metadatum.metadatum.multiple === 'no' ){
|
||||
axios.patch(`/item/${this.item_id}/metadata/${this.metadatum_id}`, {
|
||||
values: id,
|
||||
}).then(() => {
|
||||
instance.$emit('newTerm', id);
|
||||
})
|
||||
} else {
|
||||
val = ( val ) ? val : [];
|
||||
val.push( id );
|
||||
axios.patch(`/item/${this.item_id}/metadata/${this.metadatum_id}`, {
|
||||
values: val,
|
||||
}).then( () => {
|
||||
instance.$emit('newTerm', val);
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
button{
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
|
@ -1,144 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<component
|
||||
:is="getComponent()"
|
||||
v-model="valueComponent"
|
||||
:allow-new="allowNew"
|
||||
:terms="terms"
|
||||
:options="getOptions(0)"/>
|
||||
<add-new-term
|
||||
class="add-new-term"
|
||||
v-if="getComponent() !== 'tainacan-category-tag-input' && allowNew"
|
||||
:taxonomy_id="taxonomy"
|
||||
:metadatum="metadatum"
|
||||
:item_id="metadatum.item.id"
|
||||
:value="valueComponent"
|
||||
:options="getOptions(0)"
|
||||
@newTerm="reload"/>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { tainacan as axios } from '../../../js/axios/axios'
|
||||
import TainacanCategoryRadio from './CategoryRadio.vue'
|
||||
import TainacanCategoryCheckbox from './CategoryCheckbox.vue'
|
||||
import TainacanCategoryTagInput from './CategoryTaginput.vue'
|
||||
import TainacanCategorySelectbox from './CategorySelectbox.vue'
|
||||
import AddNewTerm from './AddNewTerm.vue'
|
||||
|
||||
export default {
|
||||
created(){
|
||||
let metadata_type_options = this.metadatum.metadatum.metadata_type_options;
|
||||
this.component = ( metadata_type_options && metadata_type_options.input_type )
|
||||
? this.metadatum.metadatum.metadata_type_options.input_type : this.componentAttribute
|
||||
|
||||
this.collectionId = this.metadatum.metadatum.collection_id;
|
||||
this.taxonomy = metadata_type_options.taxonomy_id;
|
||||
|
||||
if( metadata_type_options && metadata_type_options.allow_new_terms ){
|
||||
this.allowNew = metadata_type_options.allow_new_terms === 'yes'
|
||||
}
|
||||
this.getTermsFromTaxonomy();
|
||||
this.getTermsId();
|
||||
},
|
||||
components: {
|
||||
TainacanCategoryRadio,
|
||||
TainacanCategoryCheckbox,
|
||||
TainacanCategoryTagInput,
|
||||
TainacanCategorySelectbox,
|
||||
AddNewTerm
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
valueComponent: null,
|
||||
component: '',
|
||||
collectionId: '',
|
||||
taxonomy: '',
|
||||
terms:[], // object with names
|
||||
allowNew: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
valueComponent( val ){
|
||||
this.valueComponent = val;
|
||||
this.$emit('input', val);
|
||||
this.$emit('blur');
|
||||
}
|
||||
},
|
||||
props: {
|
||||
metadatum: {
|
||||
type: Object
|
||||
},
|
||||
componentAttribute: {
|
||||
type: String
|
||||
},
|
||||
value: [ Number, String, Array,Object ],
|
||||
id: ''
|
||||
},
|
||||
methods: {
|
||||
getComponent(){
|
||||
if( this.metadatum.metadatum
|
||||
&& this.metadatum.metadatum.metadata_type_options && this.metadatum.metadatum.metadata_type_options.input_type ){
|
||||
return this.metadatum.metadatum.metadata_type_options.input_type;
|
||||
}
|
||||
},
|
||||
getTermsFromTaxonomy(){
|
||||
axios.get('/taxonomy/' + this.taxonomy + '/terms?hideempty=0&order=asc' ).then( res => {
|
||||
for (let item of res.data) {
|
||||
this.terms.push( item );
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
getOptions( parent, level = 0 ){ // retrieve only ids
|
||||
let result = [];
|
||||
if ( this.terms ){
|
||||
for( let term of this.terms ){
|
||||
if( term.parent == parent ){
|
||||
term['level'] = level;
|
||||
result.push( term );
|
||||
const levelTerm = level + 1;
|
||||
const children = this.getOptions( term.id, levelTerm);
|
||||
result = result.concat( children );
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
getTermsId(){
|
||||
let values = [];
|
||||
if( this.value && this.value.length > 0){
|
||||
for( let term of this.value ){
|
||||
if( term && term.id)
|
||||
values.push(term.id);
|
||||
}
|
||||
}
|
||||
|
||||
if( values.length > 0 && this.metadatum.metadatum){
|
||||
this.valueComponent = ( this.metadatum.metadatum && this.metadatum.metadatum.multiple === 'no' ) ? values[0] : values
|
||||
}
|
||||
|
||||
},
|
||||
onInput($event) {
|
||||
this.inputValue = $event;
|
||||
this.$emit('input', this.inputValue);
|
||||
this.$emit('blur');
|
||||
},
|
||||
reload( val ){
|
||||
this.valueComponent = val;
|
||||
|
||||
this.terms = [];
|
||||
this.getTermsFromTaxonomy();
|
||||
this.getTermsId();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.add-new-term{
|
||||
margin-top: 15px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
</style>
|
|
@ -1,55 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<div
|
||||
v-for="(option, index) in options"
|
||||
:key="index">
|
||||
<b-checkbox
|
||||
:id="id"
|
||||
:style="{ paddingLeft: (option.level * 30) + 'px' }"
|
||||
:key="index"
|
||||
v-model="checked"
|
||||
@input="onChecked(option)"
|
||||
:native-value="option.id"
|
||||
border>
|
||||
{{ option.name }}
|
||||
</b-checkbox>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
created(){
|
||||
if( this.value && this.value.length > 0)
|
||||
this.checked = this.value;
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
checked: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value( val ){
|
||||
this.checked = val;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
options: {
|
||||
type: Array
|
||||
},
|
||||
value: [ Number, String, Array ]
|
||||
},
|
||||
methods: {
|
||||
onChecked() {
|
||||
this.$emit('blur');
|
||||
this.onInput(this.checked)
|
||||
},
|
||||
onInput($event) {
|
||||
this.inputValue = $event;
|
||||
this.$emit('input', this.inputValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,51 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<div
|
||||
v-for="(option, index) in options"
|
||||
:key="index">
|
||||
<b-radio
|
||||
:id="id"
|
||||
:style="{ paddingLeft: (option.level * 30) + 'px' }"
|
||||
:key="index"
|
||||
v-model="checked"
|
||||
@input="onChecked(option)"
|
||||
:native-value="option.id"
|
||||
border>
|
||||
{{ option.name }}
|
||||
</b-radio>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
checked: ( this.value ) ? this.value : ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value( val ){
|
||||
this.checked = val;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
options: {
|
||||
type: Array
|
||||
},
|
||||
value: [ Number, String, Array ]
|
||||
},
|
||||
methods: {
|
||||
onChecked() {
|
||||
this.$emit('blur');
|
||||
this.onInput(this.checked)
|
||||
},
|
||||
onInput($event) {
|
||||
this.inputValue = $event;
|
||||
this.$emit('input', this.inputValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,60 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<div class="block">
|
||||
<b-select
|
||||
:id="id"
|
||||
v-model="selected"
|
||||
@input="emitChange()"
|
||||
:placeholder="$i18n.get('label_select_category')"
|
||||
expanded>
|
||||
<option
|
||||
v-for="(option, index) in options"
|
||||
:key="index"
|
||||
:value="option.id"
|
||||
v-html="setSpaces( option.level ) + option.name"/>
|
||||
</b-select>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
created(){
|
||||
if( this.value )
|
||||
this.selected = this.value;
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
selected: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
value( val ){
|
||||
this.selected = val;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
id: String,
|
||||
options: {
|
||||
type: Array
|
||||
},
|
||||
value: [ Number, String, Array ]
|
||||
},
|
||||
methods: {
|
||||
emitChange() {
|
||||
this.$emit('input', this.selected);
|
||||
this.$emit('blur');
|
||||
},
|
||||
setSpaces( level ){
|
||||
let result = '';
|
||||
let space = ' '
|
||||
|
||||
for(let i = 0;i < level; i++)
|
||||
result += space;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,83 +0,0 @@
|
|||
<template>
|
||||
<div class="block">
|
||||
<b-taginput
|
||||
size="is-small"
|
||||
icon="magnify"
|
||||
:allow-new="allowNew"
|
||||
@input="emitChange"
|
||||
v-model="selected"
|
||||
:data="labels"
|
||||
field="label"
|
||||
attached
|
||||
:class="{'has-selected': selected != undefined && selected != []}"
|
||||
autocomplete
|
||||
@typing="search"/>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data(){
|
||||
return {
|
||||
selected: [],
|
||||
labels: []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
terms(){
|
||||
this.selectedValues();
|
||||
}
|
||||
},
|
||||
props: {
|
||||
terms: [ Number, String, Array ],
|
||||
options: {
|
||||
type: Array
|
||||
},
|
||||
value: [ Number, String, Array ],
|
||||
allowNew: [ Boolean ]
|
||||
},
|
||||
methods: {
|
||||
search( query ){
|
||||
if( this.terms && this.terms.length > 0 ){
|
||||
let result = this.terms.filter( ( item ) => {
|
||||
let name = item.name.toLowerCase();
|
||||
let q = query.toLowerCase();
|
||||
return ( name.indexOf(q) >= 0 )
|
||||
});
|
||||
this.labels = [];
|
||||
for( let term of result){
|
||||
this.labels.push({label: term.name, value: term.id})
|
||||
}
|
||||
}
|
||||
},
|
||||
selectedValues(){
|
||||
if( this.value && this.value.length > 0 && this.selected.length === 0){
|
||||
let result = this.terms.filter( ( item ) => {
|
||||
let id = item.id;
|
||||
return ( this.value.indexOf( id ) >= 0 )
|
||||
});
|
||||
|
||||
let selected = [];
|
||||
for( let term of result){
|
||||
selected.push({label: term.name, value: term.id})
|
||||
}
|
||||
this.selected = selected;
|
||||
}
|
||||
},
|
||||
emitChange(){
|
||||
let val = this.selected;
|
||||
let results = [];
|
||||
|
||||
for( let term of val ){
|
||||
if( term.value ){
|
||||
results.push( term.value );
|
||||
} else {
|
||||
results.push( term );
|
||||
}
|
||||
}
|
||||
|
||||
this.$emit('input', results);
|
||||
this.$emit('blur');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,197 +0,0 @@
|
|||
<template>
|
||||
<section
|
||||
v-if="isReady"
|
||||
:listen="setError">
|
||||
<b-field
|
||||
:addons="false"
|
||||
:type="taxonomyType"
|
||||
:message="taxonomyMessage">
|
||||
<label class="label is-inline">
|
||||
{{ $i18n.get('label_select_category') }}<span :class="taxonomyType" > * </span>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('tainacan-category', 'taxonomy_id')"
|
||||
:message="$i18n.getHelperMessage('tainacan-category', 'taxonomy_id')"/>
|
||||
</label>
|
||||
<b-select
|
||||
name="field_type_options[taxonomy_id]"
|
||||
placeholder="Select the taxonomy"
|
||||
v-model="taxonomy_id"
|
||||
@input="emitValues()"
|
||||
@focus="clear"
|
||||
:loading="loading">
|
||||
<option value="">{{ $i18n.get('label_selectbox_init') }}...</option>
|
||||
<option
|
||||
v-for="option in taxonomies"
|
||||
:value="option.id"
|
||||
:key="option.id">
|
||||
{{ option.name }}
|
||||
</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
<b-field :addons="false">
|
||||
<label class="label">
|
||||
{{ $i18n.get('label_select_category_input_type') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('tainacan-category', 'input_type')"
|
||||
:message="$i18n.getHelperMessage('tainacan-category', 'input_type')"/>
|
||||
</label>
|
||||
<b-select
|
||||
v-if="listInputType"
|
||||
name="metadata_type_options[component_type]"
|
||||
placeholder="Select the input type for the category metadatum"
|
||||
@input="emitValues()"
|
||||
v-model="input_type">
|
||||
<option
|
||||
v-for="(option, index) in single_types"
|
||||
:value="index"
|
||||
:key="index">
|
||||
{{ option }}
|
||||
</option>
|
||||
</b-select>
|
||||
|
||||
<b-select
|
||||
name="metadata_type_options[input_type]"
|
||||
placeholder="Select the input type for the category metadatum"
|
||||
v-model="input_type"
|
||||
@input="emitValues()"
|
||||
v-else>
|
||||
|
||||
<option
|
||||
v-for="(option, index) in multiple_types"
|
||||
:value="index"
|
||||
:key="index">
|
||||
{{ option }}
|
||||
</option>
|
||||
</b-select>
|
||||
|
||||
</b-field>
|
||||
|
||||
<b-field :addons="false">
|
||||
<label class="label">
|
||||
{{ $i18n.get('label_category_allow_new_terms') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('tainacan-category', 'allow_new_terms')"
|
||||
:message="$i18n.getHelperMessage('tainacan-category', 'allow_new_terms')"/>
|
||||
</label>
|
||||
<div class="block">
|
||||
<b-checkbox
|
||||
v-model="allow_new_terms"
|
||||
@input="emitValues()"
|
||||
true-value="yes"
|
||||
false-value="no">
|
||||
{{ labelNewTerms() }}
|
||||
</b-checkbox>
|
||||
</div>
|
||||
</b-field>
|
||||
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { tainacan as axios } from '../../../js/axios/axios';
|
||||
import BCheckbox from "../../../../node_modules/buefy/src/components/checkbox/Checkbox.vue";
|
||||
|
||||
export default {
|
||||
components: {BCheckbox},
|
||||
props: {
|
||||
value: [ String, Object, Array ],
|
||||
metadatum: [ String, Object ],
|
||||
errors: [ String, Object, Array ]
|
||||
},
|
||||
created(){
|
||||
this.fetchTaxonomies().then(() => {
|
||||
if ( this.value ) {
|
||||
this.taxonomy_id = this.value.taxonomy_id;
|
||||
}
|
||||
});
|
||||
|
||||
if( this.value ) {
|
||||
this.allow_new_terms = ( this.value.allow_new_terms ) ? this.value.allow_new_terms : 'no';
|
||||
}
|
||||
|
||||
this.single_types['tainacan-category-radio'] = 'Radio';
|
||||
this.single_types['tainacan-category-selectbox'] = 'Selectbox';
|
||||
this.multiple_types['tainacan-category-tag-input'] = 'Tag Input';
|
||||
this.multiple_types['tainacan-category-checkbox'] = 'Checkbox';
|
||||
|
||||
this.isReady = true;
|
||||
},
|
||||
computed: {
|
||||
listInputType(){
|
||||
if( this.metadatum && this.metadatum.multiple === 'no' ){
|
||||
let types = Object.keys( this.single_types );
|
||||
let hasValue = this.value && this.value.input_type && types.indexOf( this.value.input_type ) >= 0;
|
||||
this.setInputType( ( hasValue ) ? this.value.input_type : 'tainacan-category-radio' );
|
||||
return true;
|
||||
} else {
|
||||
let types = Object.keys( this.multiple_types );
|
||||
let hasValue = this.value && this.value.input_type && types.indexOf( this.value.input_type ) >= 0;
|
||||
this.setInputType( ( hasValue ) ? this.value.input_type : 'tainacan-category-checkbox' );
|
||||
return false;
|
||||
}
|
||||
},
|
||||
setError(){
|
||||
if( this.errors && this.errors.taxonomy_id !== '' ){
|
||||
this.setErrorsAttributes( 'is-danger', this.errors.taxonomy_id );
|
||||
} else {
|
||||
this.setErrorsAttributes( '', '' );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
isReady: false,
|
||||
taxonomies: [],
|
||||
taxonomy_id: '',
|
||||
loading: true,
|
||||
allow_new_terms: 'yes',
|
||||
input_type: 'tainacan-category-radio',
|
||||
multiple_types: {},
|
||||
single_types: {},
|
||||
taxonomyType:'',
|
||||
taxonomyMessage: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setInputType( input ){
|
||||
this.input_type = input;
|
||||
},
|
||||
setErrorsAttributes( type, message ){
|
||||
this.taxonomyType = type;
|
||||
this.taxonomyMessage = message;
|
||||
},
|
||||
fetchTaxonomies(){
|
||||
return axios.get('/taxonomies')
|
||||
.then(res => {
|
||||
let taxonomies = res.data;
|
||||
this.loading = false;
|
||||
|
||||
if( taxonomies ){
|
||||
this.taxonomies = taxonomies;
|
||||
} else {
|
||||
this.taxonomies = [];
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
this.$console.log(error);
|
||||
});
|
||||
},
|
||||
labelNewTerms(){
|
||||
return ( this.allow_new_terms === 'yes' ) ? this.$i18n.get('label_yes') : this.$i18n.get('label_no');
|
||||
},
|
||||
clear(){
|
||||
this.taxonomyType = '';
|
||||
this.taxonomyMessage = '';
|
||||
},
|
||||
emitValues(){
|
||||
this.$emit('input',{
|
||||
taxonomy_id: this.taxonomy_id,
|
||||
input_type: this.input_type,
|
||||
allow_new_terms: this.allow_new_terms
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,180 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Metadata_Types;
|
||||
|
||||
use Tainacan\Entities\Metadatum;
|
||||
use Tainacan\Entities\Item_Metadata_Entity;
|
||||
use Tainacan\Repositories\Metadata;
|
||||
|
||||
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
|
||||
|
||||
/**
|
||||
* Class TainacanMetadatumType
|
||||
*/
|
||||
class Category extends Metadata_Type {
|
||||
|
||||
function __construct(){
|
||||
// call metadatum type constructor
|
||||
parent::__construct();
|
||||
$this->set_primitive_type('term');
|
||||
|
||||
$this->set_default_options([
|
||||
'allow_new_terms' => false
|
||||
]);
|
||||
|
||||
$this->set_form_component('tainacan-form-category');
|
||||
$this->set_component('tainacan-category');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_form_labels(){
|
||||
return [
|
||||
'taxonomy_id' => [
|
||||
'title' => __( 'Collection Related', 'tainacan' ),
|
||||
'description' => __( 'Select the collection to fetch items', 'tainacan' ),
|
||||
],
|
||||
'input_type' => [
|
||||
'title' => __( 'Input type', 'tainacan' ),
|
||||
'description' => __( 'The html type of the terms list ', 'tainacan' ),
|
||||
],
|
||||
'allow_new_terms' => [
|
||||
'title' => __( 'Allow new terms', 'tainacan' ),
|
||||
'description' => __( 'Allows to create new terms', 'tainacan' ),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $itemMetadata Item_Metadata_Entity The instace of the entity itemMetadata
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function render( $itemMetadata ){
|
||||
$options = ( isset( $this->get_options()['options'] ) ) ? $this->get_options()['options'] : '';
|
||||
return '<tainacan-selectbox
|
||||
options="' . $options . '"
|
||||
metadatum_id ="'.$itemMetadata->get_metadatum()->get_id().'"
|
||||
item_id="'.$itemMetadata->get_item()->get_id().'"
|
||||
value=\''.json_encode( $itemMetadata->get_value() ).'\'
|
||||
name="'.$itemMetadata->get_metadatum()->get_name().'"></tainacan-selectbox>';
|
||||
}
|
||||
|
||||
public function validate_options( Metadatum $metadatum) {
|
||||
|
||||
if ( !in_array($metadatum->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
|
||||
return true;
|
||||
|
||||
if (empty($this->get_option('taxonomy_id')))
|
||||
return ['taxonomy_id' => __('Please select a taxonomy', 'tainacan')];
|
||||
|
||||
$Tainacan_Metadata = Metadata::get_instance();
|
||||
|
||||
$category_metadata = $Tainacan_Metadata->fetch([
|
||||
'collection_id' => $metadatum->get_collection_id(),
|
||||
'metadata_type' => 'Tainacan\\Metadata_Types\\Category'
|
||||
], 'OBJECT');
|
||||
|
||||
$category_metadata = array_map(function ($metadatum_map) {
|
||||
$fto = $metadatum_map->get_metadata_type_object();
|
||||
return [ $metadatum_map->get_id() => $fto->get_option('taxonomy_id') ];
|
||||
}, $category_metadata);
|
||||
|
||||
if( is_array( $category_metadata ) ){
|
||||
foreach ($category_metadata as $metadatum_id => $category_metadatum) {
|
||||
if ( is_array( $category_metadatum ) && key($category_metadatum) != $metadatum->get_id()
|
||||
&& in_array($this->get_option('taxonomy_id'), $category_metadatum)) {
|
||||
return ['taxonomy_id' => __('You can not have 2 taxonomy metadata using the same taxonomy in a collection.', 'tainacan')];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate item based on metadatum type categories options
|
||||
*
|
||||
* @param Item_Metadata_Entity $item_metadata
|
||||
*
|
||||
* @return bool Valid or not
|
||||
*/
|
||||
public function validate( Item_Metadata_Entity $item_metadata) {
|
||||
|
||||
$item = $item_metadata->get_item();
|
||||
|
||||
if ( !in_array($item->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
|
||||
return true;
|
||||
|
||||
$valid = true;
|
||||
|
||||
if (false === $this->get_option('allow_new_terms')) {
|
||||
$terms = $item_metadata->get_value();
|
||||
|
||||
if (false === $terms)
|
||||
return true;
|
||||
|
||||
if (!is_array($terms))
|
||||
$terms = array($terms);
|
||||
|
||||
foreach ($terms as $term) {
|
||||
if (is_object($term) && $term instanceof \Tainacan\Entities\Term) {
|
||||
$term = $term->get_id();
|
||||
}
|
||||
|
||||
if (!term_exists($term)) {
|
||||
$valid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $valid;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of an Item_Metadata_Entity using a metadatum of this metadatum 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -128,7 +128,7 @@
|
|||
this.changeValue();
|
||||
},
|
||||
isTextInputComponent( component ){
|
||||
let array = ['tainacan-relationship','tainacan-category'];
|
||||
let array = ['tainacan-relationship','tainacan-taxonomy'];
|
||||
return !( array.indexOf( component ) >= 0 );
|
||||
},
|
||||
setMetadatumTypeMessage( message ){
|
||||
|
|
|
@ -440,10 +440,10 @@ class Metadata extends Repository {
|
|||
* @see \Tainacan\Repositories\Repository::insert()
|
||||
*/
|
||||
public function insert($metadatum){
|
||||
$this->pre_update_category_metadatum($metadatum);
|
||||
$this->pre_update_taxonomy_metadatum($metadatum);
|
||||
$new_metadatum = parent::insert($metadatum);
|
||||
|
||||
$this->update_category_metadatum($new_metadatum);
|
||||
$this->update_taxonomy_metadatum($new_metadatum);
|
||||
return $new_metadatum;
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ class Metadata extends Repository {
|
|||
}
|
||||
|
||||
public function delete($metadatum_id){
|
||||
$this->delete_category_metadatum($metadatum_id);
|
||||
$this->delete_taxonomy_metadatum($metadatum_id);
|
||||
|
||||
$deleted = new Entities\Metadatum( wp_trash_post( $metadatum_id ) );
|
||||
|
||||
|
@ -815,10 +815,10 @@ class Metadata extends Repository {
|
|||
}
|
||||
|
||||
/**
|
||||
* Stores the value of the taxonomy_id option to use on update_category_metadatum method.
|
||||
* Stores the value of the taxonomy_id option to use on update_taxonomy_metadatum method.
|
||||
*
|
||||
*/
|
||||
private function pre_update_category_metadatum($metadatum) {
|
||||
private function pre_update_taxonomy_metadatum($metadatum) {
|
||||
$metadata_type = $metadatum->get_metadata_type_object();
|
||||
$current_tax = '';
|
||||
if ($metadata_type->get_primitive_type() == 'term') {
|
||||
|
@ -831,16 +831,16 @@ class Metadata extends Repository {
|
|||
}
|
||||
|
||||
/**
|
||||
* Triggers hooks when saving a Category Metadatum, indicating wich taxonomy was added or removed from a collection.
|
||||
* Triggers hooks when saving a Taxonomy Metadatum, indicating wich taxonomy was added or removed from a collection.
|
||||
*
|
||||
* This is used by Taxonomies repository to update the collections_ids property of the taxonomy as
|
||||
* a metadatum type category is inserted or removed
|
||||
* a metadatum type taxonomy is inserted or removed
|
||||
*
|
||||
* @param [type] $metadatum [description]
|
||||
*
|
||||
* @return void [type] [description]
|
||||
*/
|
||||
private function update_category_metadatum($metadatum) {
|
||||
private function update_taxonomy_metadatum($metadatum) {
|
||||
$metadata_type = $metadatum->get_metadata_type_object();
|
||||
$new_tax = '';
|
||||
|
||||
|
@ -862,7 +862,7 @@ class Metadata extends Repository {
|
|||
}
|
||||
}
|
||||
|
||||
private function delete_category_metadatum($metadatum_id) {
|
||||
private function delete_taxonomy_metadatum($metadatum_id) {
|
||||
$metadatum = $this->fetch($metadatum_id);
|
||||
$metadata_type = $metadatum->get_metadata_type_object();
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ function tainacan_autoload($class_name){
|
|||
}
|
||||
|
||||
if( in_array('Metadata_Types', $class_path) || in_array('Filter_Types', $class_path) ){
|
||||
$exceptions = ['categorytaginput','categorycheckbox','categoryselectbox'];
|
||||
$exceptions = ['taxonomytaginput','taxonomycheckbox','taxonomyselectbox'];
|
||||
if( in_array( strtolower( $class_name ), $exceptions) ){
|
||||
$dir.= 'category/';
|
||||
$dir.= 'taxonomy/';
|
||||
}else{
|
||||
$dir.= strtolower(str_replace('_', '-' , $class_name)).'/';
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ $Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Date');
|
|||
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Numeric');
|
||||
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Selectbox');
|
||||
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Relationship');
|
||||
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Category');
|
||||
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Taxonomy');
|
||||
$Tainacan_Metadata->register_metadata_type('Tainacan\Metadata_Types\Compound');
|
||||
|
||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||
|
@ -112,9 +112,9 @@ $Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Selectbox');
|
|||
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Autocomplete');
|
||||
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Taginput');
|
||||
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Checkbox');
|
||||
$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_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyTaginput');
|
||||
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyCheckbox');
|
||||
$Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomySelectbox');
|
||||
|
||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class Old_Tainacan extends Importer{
|
|||
}
|
||||
|
||||
/**
|
||||
* create taxonomies ( categories in tainacan old in first level )
|
||||
* create taxonomies ( taxonomies in tainacan old in first level )
|
||||
* next create the terms
|
||||
*
|
||||
*/
|
||||
|
@ -69,8 +69,8 @@ class Old_Tainacan extends Importer{
|
|||
foreach ($this->get_taxonomies() as $taxonomy) {
|
||||
|
||||
$tax = new Entities\Taxonomy();
|
||||
$tax->set_name( $category->name );
|
||||
$tax->set_description( $category->description );
|
||||
$tax->set_name( $taxonomy->name );
|
||||
$tax->set_description( $taxonomy->description );
|
||||
$tax->set_allow_insert('yes');
|
||||
$tax->set_status('publish');
|
||||
|
||||
|
@ -80,12 +80,12 @@ class Old_Tainacan extends Importer{
|
|||
$this->add_transient('tax_' . $term->term_id . '_id', $tax->get_id());
|
||||
$this->add_transient('tax_' . $term->term_id . '_name', $tax->get_name());
|
||||
|
||||
if (isset($category->children) && $tax) {
|
||||
$this->add_all_terms($tax, $category->children);
|
||||
if (isset($taxonomy->children) && $tax) {
|
||||
$this->add_all_terms($tax, $taxonomy->children);
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->add_error_log('Error creating taxonomy ' . $category->name );
|
||||
$this->add_error_log('Error creating taxonomy ' . $taxonomy->name );
|
||||
$this->add_error_log($tax->get_errors());
|
||||
$this->abort();
|
||||
return false;
|
||||
|
@ -191,11 +191,11 @@ class Old_Tainacan extends Importer{
|
|||
*/
|
||||
protected function get_taxonomies(){
|
||||
|
||||
$categories_link = $this->get_url() . $this->tainacan_api_address . "/categories";
|
||||
$categories = wp_remote_get($categories_link);
|
||||
$categories_array = $this->decode_request($categories);
|
||||
$taxonomies_link = $this->get_url() . $this->tainacan_api_address . "/taxonomies";
|
||||
$taxonomies = wp_remote_get($taxonomies_link);
|
||||
$taxonomies_array = $this->decode_request($taxonomies);
|
||||
|
||||
return ($categories_array) ? $categories_array : [];
|
||||
return ($taxonomies_array) ? $taxonomies_array : [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,7 +215,7 @@ class Old_Tainacan extends Importer{
|
|||
* create recursively the terms from tainacan OLD
|
||||
*
|
||||
* @param Entities\Taxonomy $taxonomy_father
|
||||
* @param array $children Array of categories from tainacan old
|
||||
* @param array $children Array of taxonomies from tainacan old
|
||||
* @param (optional) int $term_father the ID of father
|
||||
*
|
||||
* @return array
|
||||
|
@ -271,7 +271,7 @@ class Old_Tainacan extends Importer{
|
|||
$newMetadatum->set_metadata_type('Tainacan\Metadata_Types\\'.$type);
|
||||
$newMetadatum->set_parent( (isset($collection_id)) ? $collection_id : 'default');
|
||||
|
||||
if(strcmp($type, "Category") === 0){
|
||||
if(strcmp($type, "Taxonomy") === 0){
|
||||
$taxonomy_id = $meta->metadata->taxonomy;
|
||||
|
||||
$related_taxonomy = $this->get_transient('tax_' . $taxonomy_id . '_id');
|
||||
|
@ -280,7 +280,7 @@ class Old_Tainacan extends Importer{
|
|||
}
|
||||
|
||||
} else if(strcmp($type, "Relationship") === 0){
|
||||
$relation_id = $meta->metadata->object_category_id;
|
||||
$relation_id = $meta->metadata->object_taxonomy_id;
|
||||
$related_taxonomy = $this->get_transient('tax_' . $relation_id . '_id');
|
||||
$related_name = $this->get_transient('tax_' . $relation_id . '_name');
|
||||
|
||||
|
@ -350,7 +350,7 @@ class Old_Tainacan extends Importer{
|
|||
} else if(strcmp($type, 'item') === 0) {
|
||||
$type = "Relationship";
|
||||
} else if(strcmp($type, 'tree') === 0) {
|
||||
$type = "Category";
|
||||
$type = "Taxonomy";
|
||||
} else if(strcmp($type, 'compound') === 0) {
|
||||
$type = "Compound";
|
||||
} else {
|
||||
|
|
|
@ -156,7 +156,7 @@ class Test_Importer extends Importer {
|
|||
$metadatum = new Entities\Metadatum();
|
||||
$metadatum->set_name('Colora');
|
||||
$metadatum->set_collection($col1);
|
||||
$metadatum->set_metadata_type('Tainacan\Metadata_Types\Category');
|
||||
$metadatum->set_metadata_type('Tainacan\Metadata_Types\Taxonomy');
|
||||
$metadatum->set_metadata_type_options([
|
||||
'taxonomy_id' => $this->get_transient('tax_1_id'),
|
||||
'allow_new_terms' => true
|
||||
|
@ -177,7 +177,7 @@ class Test_Importer extends Importer {
|
|||
$metadatum = new Entities\Metadatum();
|
||||
$metadatum->set_name('Qualitya');
|
||||
$metadatum->set_collection($col1);
|
||||
$metadatum->set_metadata_type('Tainacan\Metadata_Types\Category');
|
||||
$metadatum->set_metadata_type('Tainacan\Metadata_Types\Taxonomy');
|
||||
$metadatum->set_metadata_type_options([
|
||||
'taxonomy_id' => $this->get_transient('tax_2_id'),
|
||||
'allow_new_terms' => true
|
||||
|
|
|
@ -1,184 +0,0 @@
|
|||
import axios from '../../../axios/axios'
|
||||
|
||||
// CATEGORIES
|
||||
export const createCategory = ({commit}, category) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
axios.tainacan.post('/taxonomies', {
|
||||
name: category.name,
|
||||
description: category.description,
|
||||
status: category.status,
|
||||
slug: category.slug,
|
||||
allow_insert: category.allowInsert
|
||||
})
|
||||
.then( res => {
|
||||
let category = res.data;
|
||||
commit('setCategory', category);
|
||||
|
||||
resolve( category );
|
||||
})
|
||||
.catch(error => {
|
||||
reject( error.response );
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteCategory = ({ commit }, categoryId) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
axios.tainacan.delete(`/taxonomies/${categoryId}?permanently=${true}`)
|
||||
.then(res => {
|
||||
commit('deleteCategory', res.data);
|
||||
|
||||
resolve( res );
|
||||
})
|
||||
.catch(error => {
|
||||
reject( error )
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const updateCategory = ({ commit }, category) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
axios.tainacan.patch(`/taxonomies/${category.categoryId}`, {
|
||||
name: category.name,
|
||||
description: category.description,
|
||||
status: category.status,
|
||||
slug: category.slug ? category.slug : '',
|
||||
allow_insert: category.allowInsert
|
||||
})
|
||||
.then( res => {
|
||||
let category = res.data;
|
||||
|
||||
commit('setCategory', category);
|
||||
|
||||
resolve( category );
|
||||
})
|
||||
.catch(error => {
|
||||
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchCategories = ({ commit }, { page, categoriesPerPage, status } ) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let endpoint = `/taxonomies?paged=${page}&perpage=${categoriesPerPage}&context=edit`;
|
||||
|
||||
if (status != undefined && status != '')
|
||||
endpoint = endpoint + '&status=' + status;
|
||||
|
||||
axios.tainacan.get(endpoint)
|
||||
.then(res => {
|
||||
let categories = res.data;
|
||||
|
||||
commit('setCategories', categories);
|
||||
|
||||
resolve({
|
||||
'categories': categories,
|
||||
'total': res.headers['x-wp-total']
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchCategory = ({ commit }, categoryId) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.get(`/taxonomies/${categoryId}`)
|
||||
.then(res => {
|
||||
let category = res.data;
|
||||
|
||||
commit('setCategory', category);
|
||||
|
||||
resolve({
|
||||
'category': category
|
||||
})
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error);
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchCategoryName = ({ commit }, categoryId) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.get(`/taxonomies/${categoryId}?fetch_only=name`)
|
||||
.then(res => {
|
||||
let name = res.data;
|
||||
|
||||
commit('setCategoryName');
|
||||
|
||||
resolve(name.name)
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
// CATEGORY TERMS
|
||||
export const sendTerm = ({commit}, { categoryId, name, description, parent, headerImageId }) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
axios.tainacan.post('/taxonomy/' + categoryId + '/terms/', {
|
||||
name: name,
|
||||
description: description,
|
||||
parent: parent,
|
||||
header_image_id: headerImageId,
|
||||
})
|
||||
.then( res => {
|
||||
let term = res.data;
|
||||
commit('setSingleTerm', term);
|
||||
resolve( term );
|
||||
})
|
||||
.catch(error => {
|
||||
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteTerm = ({ commit }, { categoryId, termId }) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
axios.tainacan.delete(`/taxonomy/${categoryId}/terms/${termId}?permanently=${true}`)
|
||||
.then(res => {
|
||||
let term = res.data;
|
||||
commit('deleteTerm', termId);
|
||||
resolve( term );
|
||||
})
|
||||
.catch(error => {
|
||||
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const updateTerm = ({ commit }, { categoryId, termId, name, description, parent, headerImageId }) => {
|
||||
return new Promise(( resolve, reject ) => {
|
||||
axios.tainacan.patch(`/taxonomy/${categoryId}/terms/${termId}`, {
|
||||
name: name,
|
||||
description: description,
|
||||
parent: parent,
|
||||
header_image_id: headerImageId,
|
||||
})
|
||||
.then( res => {
|
||||
let term = res.data;
|
||||
commit('setSingleTerm', term);
|
||||
resolve( term );
|
||||
})
|
||||
.catch(error => {
|
||||
reject({ error_message: error['response']['data'].error_message, errors: error['response']['data'].errors });
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchTerms = ({ commit }, categoryId ) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.get(`/taxonomy/${categoryId}/terms/?hideempty=0&order=asc`)
|
||||
.then(res => {
|
||||
let terms = res.data;
|
||||
commit('setTerms', terms);
|
||||
resolve( terms );
|
||||
})
|
||||
.catch(error => {
|
||||
reject( error );
|
||||
});
|
||||
});
|
||||
};
|
|
@ -1,15 +0,0 @@
|
|||
export const getCategory = state => {
|
||||
return state.category;
|
||||
};
|
||||
|
||||
export const getCategories = state => {
|
||||
return state.categories;
|
||||
};
|
||||
|
||||
export const getCategoryName = state => {
|
||||
return state.categoryName;
|
||||
};
|
||||
|
||||
export const getTerms = state => {
|
||||
return state.terms;
|
||||
};
|
|
@ -1,18 +0,0 @@
|
|||
import * as actions from './actions';
|
||||
import * as getters from './getters';
|
||||
import * as mutations from './mutations';
|
||||
|
||||
const state = {
|
||||
categories: [],
|
||||
category: {},
|
||||
categoryName: String,
|
||||
terms: []
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions,
|
||||
getters
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
import Vue from 'vue';
|
||||
|
||||
// CATEGORIES
|
||||
export const setCategory = (state, category) => {
|
||||
state.category = category;
|
||||
};
|
||||
|
||||
export const setCategories = (state, categories) => {
|
||||
state.categories = categories;
|
||||
};
|
||||
|
||||
export const setCategoryName = (state, name) => {
|
||||
state.categoryName = name;
|
||||
};
|
||||
|
||||
export const deleteCategory = ( state, category ) => {
|
||||
let index = state.categories.findIndex(deletedCategory => deletedCategory.id === category.id);
|
||||
|
||||
if (index >= 0) {
|
||||
state.categories.splice(index, 1);
|
||||
}
|
||||
};
|
||||
|
||||
// CATEGORY TERMS
|
||||
export const setSingleTerm = (state, term) => {
|
||||
|
||||
let index = state.terms.findIndex(updatedTerm => updatedTerm.id === term.id);
|
||||
if ( index >= 0){
|
||||
Vue.set( state.terms, index, term );
|
||||
} else {
|
||||
state.terms.push( term );
|
||||
}
|
||||
};
|
||||
|
||||
export const setTerms = (state, terms) => {
|
||||
state.terms = terms;
|
||||
};
|
||||
|
||||
export const deleteTerm = ( state, termId ) => {
|
||||
let index = state.terms.findIndex(deletedTerm => deletedTerm.id === termId);
|
||||
if (index >= 0) {
|
||||
state.terms.splice(index, 1);
|
||||
}
|
||||
};
|
|
@ -6,7 +6,7 @@ import collection from './modules/collection/';
|
|||
import metadata from './modules/metadata/';
|
||||
import filter from './modules/filter/';
|
||||
import search from './modules/search/';
|
||||
import category from './modules/category/';
|
||||
import taxonomy from './modules/taxonomy/';
|
||||
import event from './modules/event';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
@ -26,7 +26,7 @@ export default new Vuex.Store({
|
|||
metadata,
|
||||
filter,
|
||||
search,
|
||||
category,
|
||||
taxonomy,
|
||||
event,
|
||||
}
|
||||
})
|
|
@ -235,7 +235,7 @@ msgid "Repository Filters Page"
|
|||
msgstr "Página de Filtros do repositório"
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:57
|
||||
msgid "Categories Page"
|
||||
msgid "Taxonomies Page"
|
||||
msgstr "Página de Categorias"
|
||||
|
||||
# ESTÁ REPETIDO
|
||||
|
@ -287,7 +287,7 @@ msgstr "Página de Criação da Coleção"
|
|||
|
||||
#: admin/tainacan-admin-i18n.php:71
|
||||
#, fuzzy
|
||||
#| msgid "Category Creation Page"
|
||||
#| msgid "Taxonomy Creation Page"
|
||||
msgid "Taxonomy Creation Page"
|
||||
msgstr "Página de Criação da Taxonomia"
|
||||
|
||||
|
@ -311,7 +311,7 @@ msgstr "Editar item"
|
|||
|
||||
#: admin/tainacan-admin-i18n.php:76
|
||||
#, fuzzy
|
||||
#| msgid "Category Creation Page"
|
||||
#| msgid "Taxonomy Creation Page"
|
||||
msgid "Taxonomy Edition Page"
|
||||
msgstr "Página de Criação da Taxonomia"
|
||||
|
||||
|
@ -473,7 +473,7 @@ msgid "Collections per Page:"
|
|||
msgstr "Coleções por Página:"
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:111
|
||||
msgid "Categories per Page:"
|
||||
msgid "Taxonomies per Page:"
|
||||
msgstr "Categorias por página:"
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:112
|
||||
|
@ -561,7 +561,7 @@ msgid "Approved"
|
|||
msgstr "Aprovado"
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:130
|
||||
#: classes/metadata-types/category/class-tainacan-category.php:35
|
||||
#: classes/metadata-types/taxonomy/class-tainacan-taxonomy.php:35
|
||||
#: classes/metadata-types/relationship/class-tainacan-relationship.php:26
|
||||
msgid "Collection Related"
|
||||
msgstr "Coleção relacionada"
|
||||
|
@ -585,12 +585,12 @@ msgid "Select taxonomy"
|
|||
msgstr "Categoria pai"
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:134
|
||||
#: classes/metadata-types/category/class-tainacan-category.php:39
|
||||
#: classes/metadata-types/taxonomy/class-tainacan-taxonomy.php:39
|
||||
msgid "Input type"
|
||||
msgstr "Tipo de entrada"
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:135
|
||||
#: classes/metadata-types/category/class-tainacan-category.php:43
|
||||
#: classes/metadata-types/taxonomy/class-tainacan-taxonomy.php:43
|
||||
msgid "Allow new terms"
|
||||
msgstr "Permitir termos novos"
|
||||
|
||||
|
@ -803,7 +803,7 @@ msgid "Select all items on page"
|
|||
msgstr "Selecione um tipo de filtro."
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:188
|
||||
msgid "Delete selected categories"
|
||||
msgid "Delete selected taxonomies"
|
||||
msgstr "Deletar categorias selecionadas"
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:189
|
||||
|
@ -887,7 +887,7 @@ msgstr "Nenhuma coleção foi criada neste repositório."
|
|||
|
||||
#: admin/tainacan-admin-i18n.php:210
|
||||
#, fuzzy
|
||||
#| msgid "No category was created in this repository."
|
||||
#| msgid "No taxonomy was created in this repository."
|
||||
msgid "No taxonomy was created in this repository."
|
||||
msgstr "Nenhuma taxonomia foi criada neste repositório."
|
||||
|
||||
|
@ -921,7 +921,7 @@ msgstr "Erro ao deletar coleção."
|
|||
|
||||
#: admin/tainacan-admin-i18n.php:218
|
||||
#, fuzzy
|
||||
#| msgid "Error on deleting category"
|
||||
#| msgid "Error on deleting taxonomy"
|
||||
msgid "Error on deleting taxonomy"
|
||||
msgstr "Erro ao deletar taxonomia"
|
||||
|
||||
|
@ -982,7 +982,7 @@ msgid "Showing collections "
|
|||
msgstr "Exibindo coleções "
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:231
|
||||
msgid "Showing categories "
|
||||
msgid "Showing taxonomies "
|
||||
msgstr "Exibindo categorias "
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:232
|
||||
|
@ -1149,13 +1149,13 @@ msgstr "Caixa de verificação"
|
|||
|
||||
#: admin/tainacan-admin-i18n.php:271
|
||||
#, fuzzy
|
||||
#| msgid "Category Tag Input"
|
||||
#| msgid "Taxonomy Tag Input"
|
||||
msgid "Taxonomy Tag Input"
|
||||
msgstr "Entrada de etiquetas de taxonomia"
|
||||
|
||||
#: admin/tainacan-admin-i18n.php:272
|
||||
#, fuzzy
|
||||
#| msgid "Category Check Box"
|
||||
#| msgid "Taxonomy Check Box"
|
||||
msgid "Taxonomy Check Box"
|
||||
msgstr "Caixa de verificação de taxonomias"
|
||||
|
||||
|
@ -1592,10 +1592,10 @@ msgstr "é inválida"
|
|||
#, fuzzy
|
||||
#| msgid ""
|
||||
#| "Compound metadata do not support metadata with multiple values (except "
|
||||
#| "categories)"
|
||||
#| "taxonomies)"
|
||||
msgid ""
|
||||
"Compound metadata do not support metadata with multiple values (except "
|
||||
"categories)"
|
||||
"taxonomies)"
|
||||
msgstr ""
|
||||
"Metadados compostos não suportam metadados com vários valores (exceto "
|
||||
"categorias)"
|
||||
|
@ -1604,7 +1604,7 @@ msgstr ""
|
|||
#: classes/entities/class-tainacan-metadatum.php:441
|
||||
#, fuzzy
|
||||
#| msgid ""
|
||||
#| "Category metadata can not be used inside Compound metadata with multiple "
|
||||
#| "Taxonomy metadata can not be used inside Compound metadata with multiple "
|
||||
#| "values"
|
||||
msgid ""
|
||||
"Taxonomy metadata can not be used inside Compound metadata with multiple "
|
||||
|
@ -1649,26 +1649,26 @@ msgstr "Novo termo de gênero"
|
|||
msgid "You can not have two terms with the same name at the same level"
|
||||
msgstr "Você não pode ter dois termos com o mesmo nome em um mesmo nível"
|
||||
|
||||
#: classes/metadata-types/category/class-tainacan-category.php:36
|
||||
#: classes/metadata-types/taxonomy/class-tainacan-taxonomy.php:36
|
||||
#: classes/metadata-types/relationship/class-tainacan-relationship.php:27
|
||||
msgid "Select the collection to fetch items"
|
||||
msgstr "Selecione a coleção para buscar itens"
|
||||
|
||||
#: classes/metadata-types/category/class-tainacan-category.php:40
|
||||
#: classes/metadata-types/taxonomy/class-tainacan-taxonomy.php:40
|
||||
msgid "The html type of the terms list "
|
||||
msgstr "O tipo de html utilizado na lista de termos"
|
||||
|
||||
#: classes/metadata-types/category/class-tainacan-category.php:44
|
||||
#: classes/metadata-types/taxonomy/class-tainacan-taxonomy.php:44
|
||||
msgid "Allows to create new terms"
|
||||
msgstr "Permite a criação de novos termos"
|
||||
|
||||
#: classes/metadata-types/category/class-tainacan-category.php:70
|
||||
#: classes/metadata-types/taxonomy/class-tainacan-taxonomy.php:70
|
||||
#, fuzzy
|
||||
#| msgid "Please select a category"
|
||||
#| msgid "Please select a taxonomy"
|
||||
msgid "Please select a taxonomy"
|
||||
msgstr "Por favor, selecione uma taxonomia."
|
||||
|
||||
#: classes/metadata-types/category/class-tainacan-category.php:88
|
||||
#: classes/metadata-types/taxonomy/class-tainacan-taxonomy.php:88
|
||||
#, fuzzy
|
||||
#| msgid ""
|
||||
#| "You can not have 2 taxonomy metadata using the same taxonomy in a "
|
||||
|
@ -2640,37 +2640,37 @@ msgstr "Selecione uma opção"
|
|||
msgid "Collection: %s"
|
||||
msgstr "Coleções: %s"
|
||||
|
||||
#~ msgid "Category Select Box"
|
||||
#~ msgid "Taxonomy Select Box"
|
||||
#~ msgstr "Lista de seleção de taxonomias"
|
||||
|
||||
#~ msgid "Category"
|
||||
#~ msgid "Taxonomy"
|
||||
#~ msgstr "Taxonomia"
|
||||
|
||||
# MUITO IMPRECISA!!!!!!!!!!!
|
||||
#~ msgid "Category Terms"
|
||||
#~ msgid "Taxonomy Terms"
|
||||
#~ msgstr "Termos de Categorias"
|
||||
|
||||
#~ msgid "Category deleted"
|
||||
#~ msgid "Taxonomy deleted"
|
||||
#~ msgstr "Taxonomia deletada"
|
||||
|
||||
#~ msgid "Do you really want to delete this category?"
|
||||
#~ msgid "Do you really want to delete this taxonomy?"
|
||||
#~ msgstr "Você realmente deseja deletar esta taxonomia?"
|
||||
|
||||
#~ msgid "Category Edition Page"
|
||||
#~ msgid "Taxonomy Edition Page"
|
||||
#~ msgstr "Página de edição da taxonomia"
|
||||
|
||||
#~ msgid "Select category"
|
||||
#~ msgid "Select taxonomy"
|
||||
#~ msgstr "Selecionar taxonomia"
|
||||
|
||||
#~ msgid "Are you sure? The category is not saved, changes will be lost."
|
||||
#~ msgid "Are you sure? The taxonomy is not saved, changes will be lost."
|
||||
#~ msgstr ""
|
||||
#~ "Opa, tem certeza? Como a taxonomia não foi salva, as alterações podem ser "
|
||||
#~ "perdidas"
|
||||
|
||||
#~ msgid "Category Page"
|
||||
#~ msgid "Taxonomy Page"
|
||||
#~ msgstr "Página da Taxonomia"
|
||||
|
||||
#~ msgid "Categories"
|
||||
#~ msgid "Taxonomies"
|
||||
#~ msgstr "Taxonomies"
|
||||
|
||||
#~ msgid "exposer_mapping"
|
||||
|
|
|
@ -85,7 +85,7 @@ function tainacan_migrate_post_type_field_to_metadatum(){
|
|||
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Category'],
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Taxonomy'],
|
||||
['meta_value' => 'Tainacan\Field_Types\Category'],
|
||||
'%s', '%s');
|
||||
|
||||
|
@ -96,57 +96,75 @@ function tainacan_migrate_post_type_field_to_metadatum(){
|
|||
'%s', '%s');
|
||||
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Core_Description'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Core_Description'],
|
||||
'%s', '%s');
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Core_Description'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Core_Description'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Core_Title'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Core_Title'],
|
||||
'%s', '%s');
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Core_Title'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Core_Title'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Text'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Text'],
|
||||
'%s', '%s');
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Text'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Text'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Textarea'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Textarea'],
|
||||
'%s', '%s');
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Textarea'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Textarea'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Date'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Date'],
|
||||
'%s', '%s');
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Date'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Date'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Numeric'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Numeric'],
|
||||
'%s', '%s');
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Numeric'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Numeric'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Selectbox'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Selectbox'],
|
||||
'%s', '%s');
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Selectbox'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Selectbox'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Relationship'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Relationship'],
|
||||
'%s', '%s');
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Relationship'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Relationship'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Compound'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Compound'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Taxonomy'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Category'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Taxonomy'],
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Category'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Category'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Category'],
|
||||
'%s', '%s');
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Filter_Types\TaxonomyTaginput'],
|
||||
['meta_value' => 'Tainacan\Filter_Types\CategoryTaginput'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Filter_Types\TaxonomyCheckbox'],
|
||||
['meta_value' => 'Tainacan\Filter_Types\CategoryCheckbox'],
|
||||
'%s', '%s');
|
||||
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Metadata_Types\Compound'],
|
||||
['meta_value' => 'Tainacan\Metadatum_Types\Compound'],
|
||||
'%s', '%s');
|
||||
$wpdb->update($wpdb->postmeta,
|
||||
['meta_value' => 'Tainacan\Filter_Types\TaxonomySelectbox'],
|
||||
['meta_value' => 'Tainacan\Filter_Types\CategorySelectbox'],
|
||||
'%s', '%s');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@ use Tainacan\Entities;
|
|||
/**
|
||||
* Sample test case.
|
||||
*/
|
||||
class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
|
||||
class TaxonomyMetadatumTypes extends TAINACAN_UnitTestCase {
|
||||
|
||||
|
||||
function test_category_metadata_types() {
|
||||
function test_taxonomy_metadata_types() {
|
||||
|
||||
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
||||
$Tainacan_Item_Metadata = \Tainacan\Repositories\Item_Metadata::get_instance();
|
||||
|
@ -45,7 +45,7 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
'name' => 'meta',
|
||||
'description' => 'description',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Category',
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
|
||||
'status' => 'publish',
|
||||
'metadata_type_options' => [
|
||||
'taxonomy_id' => $tax->get_id(),
|
||||
|
@ -72,7 +72,7 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
'name' => 'meta2',
|
||||
'description' => 'description',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Category',
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
|
||||
'status' => 'draft',
|
||||
),
|
||||
true
|
||||
|
@ -122,13 +122,13 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
$this->assertEquals('Tainacan\Entities\Term', get_class($check_item_metadata->get_value()));
|
||||
|
||||
// test 2 metadata with same category
|
||||
// test 2 metadata with same taxonomy
|
||||
$metadatum2->set_metadata_type_options([
|
||||
'taxonomy_id' => $tax->get_id(),
|
||||
]);
|
||||
$metadatum2->set_status('publish');
|
||||
|
||||
$this->assertFalse($metadatum2->validate(), 'Category Metadatum should not validate when using a category in use by another metadatum in the same collection');
|
||||
$this->assertFalse($metadatum2->validate(), 'Taxonomy Metadatum should not validate when using a taxonomy in use by another metadatum in the same collection');
|
||||
$errors = $metadatum2->get_errors();
|
||||
$this->assertInternalType('array', $errors);
|
||||
$this->assertArrayHasKey('taxonomy_id', $errors[0]['metadata_type_options']);
|
||||
|
@ -168,7 +168,7 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
'name' => 'meta',
|
||||
'description' => 'description',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Category',
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
|
||||
'status' => 'publish',
|
||||
'metadata_type_options' => [
|
||||
'taxonomy_id' => $tax->get_id(),
|
||||
|
@ -243,7 +243,7 @@ class CategoryMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
'name' => 'meta',
|
||||
'description' => 'description',
|
||||
'collection' => $collection,
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Category',
|
||||
'metadata_type' => 'Tainacan\Metadata_Types\Taxonomy',
|
||||
'status' => 'publish',
|
||||
'metadata_type_options' => [
|
||||
'taxonomy_id' => $tax->get_id(),
|
||||
|
|
|
@ -248,7 +248,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
}
|
||||
|
||||
function test_validations_category_in_multiple() {
|
||||
function test_validations_taxonomy_in_multiple() {
|
||||
|
||||
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
||||
|
||||
|
@ -275,10 +275,10 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
$newMetadatum = new \Tainacan\Entities\Metadatum();
|
||||
$newMetadatum->set_name('test_multiple');
|
||||
$newMetadatum->set_metadata_type('Tainacan\Metadata_Types\Category');
|
||||
$newMetadatum->set_metadata_type('Tainacan\Metadata_Types\Taxonomy');
|
||||
$newMetadatum->set_parent($metadatum->get_id());
|
||||
|
||||
$this->assertFalse($newMetadatum->validate(), 'You cant add a category metadatum inside a multiple compound metadatum');
|
||||
$this->assertFalse($newMetadatum->validate(), 'You cant add a taxonomy metadatum inside a multiple compound metadatum');
|
||||
|
||||
$newMetadatum->set_metadata_type('Tainacan\Metadata_Types\Text');
|
||||
$this->assertTrue($newMetadatum->validate());
|
||||
|
@ -286,7 +286,7 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
}
|
||||
|
||||
function test_validations_category_in_multiple_2() {
|
||||
function test_validations_taxonomy_in_multiple_2() {
|
||||
|
||||
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
||||
|
||||
|
@ -313,15 +313,15 @@ class CompoundMetadatumTypes extends TAINACAN_UnitTestCase {
|
|||
|
||||
$newMetadatum = new \Tainacan\Entities\Metadatum();
|
||||
$newMetadatum->set_name('test_multiple');
|
||||
$newMetadatum->set_metadata_type('Tainacan\Metadata_Types\Category');
|
||||
$newMetadatum->set_metadata_type('Tainacan\Metadata_Types\Taxonomy');
|
||||
$newMetadatum->set_parent($metadatum->get_id());
|
||||
|
||||
$this->assertTrue($newMetadatum->validate(), 'You can add a category metadatum inside a not multiple compound metadatum');
|
||||
$this->assertTrue($newMetadatum->validate(), 'You can add a taxonomy metadatum inside a not multiple compound metadatum');
|
||||
$newMetadatum = $Tainacan_Metadata->insert($newMetadatum);
|
||||
|
||||
$metadatum->set_multiple('yes');
|
||||
|
||||
$this->assertFalse($metadatum->validate(), 'You cant turn a compound metadatum into multiple when there is a category metadatum inside it');
|
||||
$this->assertFalse($metadatum->validate(), 'You cant turn a compound metadatum into multiple when there is a taxonomy metadatum inside it');
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue