diff --git a/src/admin/components/items-list.vue b/src/admin/components/items-list.vue
index 5abebd775..172c2cd75 100644
--- a/src/admin/components/items-list.vue
+++ b/src/admin/components/items-list.vue
@@ -26,9 +26,8 @@
-
-
-
+
+
@@ -55,7 +54,8 @@ export default {
},
methods: {
...mapActions('collection', [
- 'fetchItems'
+ 'fetchItems',
+ 'deleteItem'
]),
...mapGetters('collection', [
'getItems'
@@ -63,11 +63,13 @@ export default {
handleSelectionChange(value) {
this.multipleSelection = value;
},
- shareItem(itemId) {
-
+ deleteOneItem(itemId) {
+ this.$dialog.confirm({
+ message: 'Deseja realmente deletar este Item?',
+ onConfirm: () => this.deleteItem(itemId)
+ });
},
showMoreItem(itemId) {
-
}
},
computed: {
diff --git a/src/admin/scss/tainacan-admin.scss b/src/admin/scss/tainacan-admin.scss
index 44423f77a..cbc34f0c4 100644
--- a/src/admin/scss/tainacan-admin.scss
+++ b/src/admin/scss/tainacan-admin.scss
@@ -26,6 +26,9 @@ $link: $primary;
$link-invert: $primary-invert;
$link-focus-border: $primary;
+// Bulma's modal (needs to be greather than taincan-admin-app
+$modal-z: 9999999;
+
// Import Bulma and Buefy styles
@import "../../assets/css/fonts/materialdesignicons.css";
@import "../../../node_modules/bulma/bulma.sass";
diff --git a/src/classes/field-types/tainacan-form-item.vue b/src/classes/field-types/tainacan-form-item.vue
index eeb574747..8dc078b52 100644
--- a/src/classes/field-types/tainacan-form-item.vue
+++ b/src/classes/field-types/tainacan-form-item.vue
@@ -3,10 +3,10 @@
:message="getErrorMessage"
:type="fieldTypeMessage">
-
+
@@ -56,13 +56,10 @@
getValue(){
if (this.field.value instanceof Array) {
this.inputs = this.field.value;
- if (this.inputs.length == 0)
- this.inputs.push('');
- } else {
- if (this.field.value == null || this.field.value == undefined)
+ if (this.inputs.length == 0)
this.inputs.push('');
- else
- this.inputs.push(this.field.value);
+ } else {
+ this.field.value == null || this.field.value == undefined ? this.inputs.push('') : this.inputs.push(this.field.value);
}
},
addInput(){
diff --git a/src/js/store/modules/collection/actions.js b/src/js/store/modules/collection/actions.js
index 9670b25ee..669bffe2c 100644
--- a/src/js/store/modules/collection/actions.js
+++ b/src/js/store/modules/collection/actions.js
@@ -9,6 +9,19 @@ export const fetchItems = ({ commit, state }, collectionId) => {
.catch(error => console.log( error ));
}
+export const deleteItem = ({ commit }, item_id ) => {
+ return new Promise((resolve, reject) => {
+ axios.delete('/items/' + item_id)
+ .then( res => {
+ commit('deleteItem', { id: item_id });
+ resolve( res );
+ }).catch( error => {
+ reject( error );
+ });
+
+ });
+};
+
export const fetchCollections = ({ commit }) => {
axios.get('/collections')
.then(res => {
diff --git a/src/js/store/modules/collection/mutations.js b/src/js/store/modules/collection/mutations.js
index 3423c0d1b..556f76258 100644
--- a/src/js/store/modules/collection/mutations.js
+++ b/src/js/store/modules/collection/mutations.js
@@ -2,6 +2,13 @@ export const setItems = ( state, items ) => {
state.items = items;
}
+export const deleteItem = ( state, item ) => {
+ let index = state.items.findIndex(deletedItem => deletedItem.id === item.id);
+ if (index >= 0) {
+ state.items.splice(index, 1);
+ }
+}
+
export const setCollections = (state, collections) => {
state.collections = collections;
}
diff --git a/src/js/store/modules/item/actions.js b/src/js/store/modules/item/actions.js
index 6a5466d23..9478ffb0f 100644
--- a/src/js/store/modules/item/actions.js
+++ b/src/js/store/modules/item/actions.js
@@ -80,7 +80,7 @@ export const sendItem = ( { commit }, { collection_id, title, description, statu
};
- export const updateItem = ({ commit }, { item_id, title, description, status }) => {
+export const updateItem = ({ commit }, { item_id, title, description, status }) => {
return new Promise((resolve, reject) => {
axios.patch('/items/' + item_id, {
title: title,
@@ -93,5 +93,5 @@ export const sendItem = ( { commit }, { collection_id, title, description, statu
reject( error.response );
});
- });
-};
\ No newline at end of file
+ });
+};
diff --git a/src/js/store/modules/item/getters.js b/src/js/store/modules/item/getters.js
index 4a1987a3d..d33ad3132 100644
--- a/src/js/store/modules/item/getters.js
+++ b/src/js/store/modules/item/getters.js
@@ -6,7 +6,3 @@ export const getFields = state => {
export const getItem = state => {
return state.item;
}
-
-export const getError = state => {
- return state.error;
-}
\ No newline at end of file
diff --git a/src/js/store/modules/item/mutations.js b/src/js/store/modules/item/mutations.js
index 300acc92a..448a44e9c 100644
--- a/src/js/store/modules/item/mutations.js
+++ b/src/js/store/modules/item/mutations.js
@@ -1,6 +1,5 @@
import Vue from 'vue';
-
export const setItem = ( state, item ) => {
state.item = item;
}