diff --git a/src/components/pages/PanelAdministrator.vue b/src/components/pages/PanelAdministrator.vue index 9c96fba309b5a8cb191c1e707d15a758865e2174..89e792b0612c8da04dbb432308d87affd4c832af 100644 --- a/src/components/pages/PanelAdministrator.vue +++ b/src/components/pages/PanelAdministrator.vue @@ -24,7 +24,7 @@ </b-card> </b-tab> <b-tab v-if="this.$store.state.user.role == 2" title="Pengaturan Admin"> - <table-budget :dataTable='dataTable' :key='dataTable.current_item.id' v-on:changeActivity="updateActivity($event)" /> + <table-budget :dataTable='dataTable' :key='dataTable.current_item.admin_name' v-on:changeActivity="updateActivity($event)" v-on:backState="backState()"/> </b-tab> </b-tabs> </b-card> @@ -136,7 +136,11 @@ export default { // { value: '2', text: 'William Rukmansa' }, // { value: '3', text: 'Ricky Kennedy' } ], - } + isNotTop : false, + }, + dataStack : [ + + ] } }, created : function() { @@ -182,12 +186,9 @@ export default { this.dataTable.current_item.id = id; this.dataTable.current_item.activity_name = activity_name; this.dataTable.current_item.admin_name = admin_name; - console.log(this.dataTable.current_item.activity_name) }, updateActivity: function(event) { - console.log("update") - console.log(event) this.fillDataTable(event.$oid) }, @@ -214,6 +215,7 @@ export default { }, fillDataTable : function(idPage) { if (idPage === 'top') { + this.dataTable.items = [] let fetchData = { method: 'POST', body: JSON.stringify({ year: 2019, return_admin : true }), @@ -236,10 +238,11 @@ export default { this.dataTable.current_item.admin_name = response.admin.name this.dataTable.current_item.activity_name = response.data.name + this.dataStack.push(idPage); } }) + this.dataTable.isNotTop = false } else { - console.log('this the id Page' +idPage) let fetchData = { method: 'POST', body: JSON.stringify({ page_id: idPage , return_admin : true }), @@ -250,8 +253,6 @@ export default { .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 = '--' @@ -264,15 +265,21 @@ export default { 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("here the response error") - console.log(response) + this.dataStack.push(idPage); } }) + this.dataTable.isNotTop = true } + }, + backState : function() { + alert("back") + this.dataStack.pop() + let current= this.dataStack.pop() + console.log(current) + this.fillDataTable(current) + } } } diff --git a/src/components/partials/TableBudget.vue b/src/components/partials/TableBudget.vue index a79ea21de0d460a07badccf85ef43093216bbc90..de4fecc279ac545bb1a0f59bbd4e074b255a04ea 100644 --- a/src/components/partials/TableBudget.vue +++ b/src/components/partials/TableBudget.vue @@ -3,9 +3,9 @@ <b-col> <b-row align-h='left'> <h3> - {{ "Activity : " + dataTable.current_item.activity_name }} + {{ "Activity : " + currentItemActivity }} <br><br> - {{"Admin : " + dataTable.current_item.admin_name}} + {{"Admin : " + currentItemAdmin}} </h3> </b-row> <b-row v-if="showCard"> @@ -33,7 +33,10 @@ </b-button> </b-card> </b-row> - <b-row class="my-2" align-h="end"> + <b-row class="my-2" align-h="space-between"> + <b-col class="pl-0"> + <b-button v-on:click="backState()" v-if="dataTable.isNotTop" variant="outline-secondary" size="sm"> kembali </b-button> + </b-col> <b-col v-if="dataTable.current_item.admin_name === '--'" cols="auto" @@ -50,6 +53,8 @@ v-else cols="auto" > + + <b-button v-on:click="changeShowCardState()" variant="primary" @@ -140,15 +145,20 @@ export default { } }, watch : { - dataTable() { - alert("sikat") - this.isBusy = false + currentItemAdmin() { + console.log(currentItemActivity) } }, computed: { rows() { return this.dataTable.items.length - } + }, + currentItemAdmin() { + return this.dataTable.current_item.admin_name + }, + currentItemActivity() { + return this.dataTable.current_item.activity_name + }, }, methods: { getData : function() { @@ -177,24 +187,39 @@ export default { if(this.selected === 0) { alert('pilihan tidak valid') } else { - - 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" } } - - 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; + for(let i in this.dataTable.options){ + if(this.dataTable.options[i].value === this.selected){ + this.dataTable.current_item.admin_name = this.dataTable.options[i].text; + break; + } + } } }) + + // fetchData = { + // method: 'POST', + // body: JSON.stringify({page_id : this.dataTable.current_item.id}), + // headers: { "Content-Type": "application/json" } + // } + + // fetch(`${this.$store.state.baseUrl}/api/admin/get-admin`, fetchData) + // .then(response => response.json()) + // .then(response => { + // if(response.status === 200) { + // console.log(response) + // this.dataTable.current_item.admin_name = response.data.name; + // } + // }) } }, seeDetail : function(row) { @@ -204,6 +229,10 @@ export default { showModal : function() { this.modalVisibility = true; }, + backState : function() { + // this.isBusy = true + this.$emit('backState'); + }, }, created : function() {