diff --git a/src/components/pages/PanelAdministrator.vue b/src/components/pages/PanelAdministrator.vue index 906dc65b10fd3446929c47dbc30c1c0a9306c695..9c96fba309b5a8cb191c1e707d15a758865e2174 100644 --- a/src/components/pages/PanelAdministrator.vue +++ b/src/components/pages/PanelAdministrator.vue @@ -186,15 +186,9 @@ export default { }, updateActivity: function(event) { - var element = this.dataTable.items.find( function(element){ - if (element.id === event ){ - console.log("before"); - console.log(element); - return element; - } - }) - - this.updateCurrentActivity(element.id, element.activity_name, element.admin_name); + console.log("update") + console.log(event) + this.fillDataTable(event.$oid) }, fillAdmin : function() { @@ -218,8 +212,8 @@ export default { } }) }, - fillDataTable : function(id) { - if (id === 'top') { + fillDataTable : function(idPage) { + if (idPage === 'top') { let fetchData = { method: 'POST', body: JSON.stringify({ year: 2019, return_admin : true }), @@ -230,27 +224,55 @@ export default { .then(response => response.json()) .then(response => { if(response.status === 200) { + for ( let i =0 ; i < response.subdata.length; i++) { + let admin = '--' + if (response.admin_subdata[i] !== null) { + admin = response.admin_subdata[i].name + } + this.dataTable.items.push({id:response.subdata[i]._id, activity_name:response.subdata[i].name, admin_name : admin}) + } + + this.dataTable.current_item.id = response.data._id.$oid + this.dataTable.current_item.admin_name = response.admin.name + this.dataTable.current_item.activity_name = response.data.name + + } + }) + } else { + console.log('this the id Page' +idPage) + let fetchData = { + method: 'POST', + body: JSON.stringify({ page_id: idPage , return_admin : true }), + headers: { "Content-Type": "application/json" } + } + + fetch(`${this.$store.state.baseUrl}/api/page/get`, fetchData) + .then(response => response.json()) + .then(response => { + if(response.status === 200) { + console.log("here the response") console.log(response) + this.dataTable.items = [] for ( let i =0 ; i < response.subdata.length; i++) { let admin = '--' - console.log(response.admin_subdata[3]) if (response.admin_subdata[i] !== null) { admin = response.admin_subdata[i].name - alert(admin) } this.dataTable.items.push({id:response.subdata[i]._id, activity_name:response.subdata[i].name, admin_name : admin}) } + + this.dataTable.current_item.id = response.data._id.$oid + this.dataTable.current_item.admin_name = response.admin.name + this.dataTable.current_item.activity_name = response.data.name - console.log("filled items") - console.log(this.dataTable.items) } else { - - console.log("this response") + console.log("here the response error") console.log(response) } + }) } - } + }, } } diff --git a/src/components/partials/TableBudget.vue b/src/components/partials/TableBudget.vue index 425a20e61d1966b42b490fb71c2caabb828682b0..a79ea21de0d460a07badccf85ef43093216bbc90 100644 --- a/src/components/partials/TableBudget.vue +++ b/src/components/partials/TableBudget.vue @@ -176,23 +176,26 @@ export default { updateAdmin : function() { if(this.selected === 0) { alert('pilihan tidak valid') - } - let fetchData = { - method: 'POST', - body: JSON.stringify({page_id : this.dataTable.current_item.id.$oid, admin_id: this.selected}), - headers: { "Content-Type": "application/json" } - } + } else { - console.log(fetchData) - - fetch(`${this.$store.state.baseUrl}/api/admin/add-page`, fetchData) - .then(response => response.json()) - .then(response => { - if(response.status === 200) { - alert("berhasil"); + console.log(this.dataTable.current_item) + let fetchData = { + method: 'POST', + body: JSON.stringify({page_id : this.dataTable.current_item.id, admin_id: this.selected}), + headers: { "Content-Type": "application/json" } } - }) - this.dataTable.current_item.admin_name = this.options[this.selected].text; + + console.log(fetchData) + + fetch(`${this.$store.state.baseUrl}/api/admin/add-page`, fetchData) + .then(response => response.json()) + .then(response => { + if(response.status === 200) { + alert("berhasil"); + this.dataTable.current_item.admin_name = this.options[this.selected].text; + } + }) + } }, seeDetail : function(row) { // this.isBusy = true