Added delete to terminals
This commit is contained in:
parent
ea34bf3e80
commit
11dca03aa8
|
@ -22,6 +22,17 @@ export function updateTerminal(data) {
|
||||||
return axios.put(`${TerminalEndpointUrl}/terminal/${data._id}`, dto)
|
return axios.put(`${TerminalEndpointUrl}/terminal/${data._id}`, dto)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function deleteTerminal(data) {
|
||||||
|
// put this logic in the .vue file
|
||||||
|
if (data !== '') {
|
||||||
|
console.log(data)
|
||||||
|
const chad = `${TerminalEndpointUrl}/terminal/${data}?secret=MySecretForTerminal&platform=${store.state.platform}`
|
||||||
|
// return axios.delete(${ProductEndpointUrl}/fuels/${data}?secret=MySecretForTermina&platform=${store.state.platform})
|
||||||
|
return chad
|
||||||
|
}
|
||||||
|
return 'error'
|
||||||
|
}
|
||||||
|
|
||||||
function __dataToDTO(data) {
|
function __dataToDTO(data) {
|
||||||
return {
|
return {
|
||||||
'name': data.name,
|
'name': data.name,
|
||||||
|
|
|
@ -45,6 +45,8 @@
|
||||||
<script>
|
<script>
|
||||||
// const deleteProduct = require('@/api/product').deleteProduct
|
// const deleteProduct = require('@/api/product').deleteProduct
|
||||||
import { deleteProduct } from '@/api/product'
|
import { deleteProduct } from '@/api/product'
|
||||||
|
import { deleteTerminal } from '@/api/terminal'
|
||||||
|
// import { `delete${this.type}` } from `@/api/${this.type}`
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DeletePopUp',
|
name: 'DeletePopUp',
|
||||||
|
@ -53,7 +55,7 @@ export default {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: function() {
|
default: function() {
|
||||||
return {
|
return {
|
||||||
name: 'BROKEN!-KEROSENOS-BROKEN!',
|
name: 'BROKEN!-BROKEN!',
|
||||||
_id: 'THIS-ID-IS-BROKEN!'
|
_id: 'THIS-ID-IS-BROKEN!'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +93,13 @@ export default {
|
||||||
},
|
},
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
console.log(this.item._id)
|
console.log(this.item._id)
|
||||||
|
if (this.type === 'terminal') {
|
||||||
|
console.log(deleteTerminal(this.item._id))
|
||||||
|
} else {
|
||||||
|
console.log(deleteProduct(this.item._id))
|
||||||
|
}
|
||||||
console.log(deleteProduct(this.item._id))
|
console.log(deleteProduct(this.item._id))
|
||||||
|
// delete${this.type}(this.item._id))
|
||||||
// .then((r) => {
|
// .then((r) => {
|
||||||
// console.log(r)
|
// console.log(r)
|
||||||
// })
|
// })
|
||||||
|
|
|
@ -1,111 +0,0 @@
|
||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-button icon="el-icon-delete" size="mini" type="danger" @click="openDeletePopup">
|
|
||||||
Delete
|
|
||||||
</el-button>
|
|
||||||
<el-dialog :visible.sync="dialogVisible">
|
|
||||||
<div v-if="viewState==='initialState'">
|
|
||||||
<div>
|
|
||||||
<h3>
|
|
||||||
Are you sure you want to delete this {{ type }} ?
|
|
||||||
</h3>
|
|
||||||
<p>To delete this {{ type }}, type in <b>{{ item.name }}</b> and click delete</p>
|
|
||||||
</div>
|
|
||||||
<el-row :gutter="20">
|
|
||||||
<el-col :span="12" :offset="6">
|
|
||||||
<div class="inputBox">
|
|
||||||
<el-input v-model="input" placeholder="Please input" />
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-button @click="dialogVisible = false">
|
|
||||||
Cancel
|
|
||||||
</el-button>
|
|
||||||
<el-button type="danger" :disabled="isNameCorrect" @click="handleSubmit">
|
|
||||||
Confirm
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="viewState==='Success'">
|
|
||||||
<h1>SUCCESS you can now close this popup</h1>
|
|
||||||
<h1>{{ item._id }}</h1>
|
|
||||||
<el-button @click="dialogVisible = false">
|
|
||||||
Close
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<div v-else-if="viewState==='Error'">
|
|
||||||
<h1>ERROR please try again, if the error persist contact Chadmin!</h1>
|
|
||||||
<el-button @click="dialogVisible = false">
|
|
||||||
Close
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// const deleteProduct = require('@/api/product').deleteProduct
|
|
||||||
import { deleteProduct } from '@/api/product'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
item: {
|
|
||||||
type: Object,
|
|
||||||
default: function() {
|
|
||||||
return {
|
|
||||||
name: 'BROKEN!-KEROSENOS-BROKEN!',
|
|
||||||
_id: 'THIS-ID-IS-BROKEN!'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
default: 'chad'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogVisible: false,
|
|
||||||
viewState: 'initialState',
|
|
||||||
isNameCorrect: true,
|
|
||||||
input: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
input: function() {
|
|
||||||
if (this.input === this.item.name) {
|
|
||||||
this.isNameCorrect = false
|
|
||||||
} else {
|
|
||||||
this.isNameCorrect = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
openDeletePopup() {
|
|
||||||
this.dialogVisible = true
|
|
||||||
this.viewState = 'initialState'
|
|
||||||
this.input = ''
|
|
||||||
},
|
|
||||||
checkAllSuccess() {
|
|
||||||
return Object.keys(this.listObj).every(item => this.listObj[item].hasSuccess)
|
|
||||||
},
|
|
||||||
handleSubmit() {
|
|
||||||
console.log(this.item._id)
|
|
||||||
console.log(deleteProduct(this.item._id))
|
|
||||||
// .then((r) => {
|
|
||||||
// console.log(r)
|
|
||||||
// })
|
|
||||||
if (this.input) {
|
|
||||||
this.viewState = 'Success'
|
|
||||||
} else if (!this.input) {
|
|
||||||
this.viewState = 'Error'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.inputBox {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -42,7 +42,7 @@
|
||||||
</router-link>
|
</router-link>
|
||||||
<deletePopUp
|
<deletePopUp
|
||||||
:item="scope.row"
|
:item="scope.row"
|
||||||
:type="'Product'"
|
:type="'product'"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
|
@ -22,6 +22,10 @@
|
||||||
Edit
|
Edit
|
||||||
</el-button>
|
</el-button>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
<deletePopUp
|
||||||
|
:item="scope.row"
|
||||||
|
:type="'terminal'"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
@ -33,10 +37,11 @@
|
||||||
<script>
|
<script>
|
||||||
import { fetchList } from '@/api/terminal'
|
import { fetchList } from '@/api/terminal'
|
||||||
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
|
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
|
||||||
|
import DeletePopUp from '@/components/PopUps/Delete'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ArticleList',
|
name: 'ArticleList',
|
||||||
components: { Pagination },
|
components: { Pagination, DeletePopUp },
|
||||||
filters: {
|
filters: {
|
||||||
statusFilter(status) {
|
statusFilter(status) {
|
||||||
const statusMap = {
|
const statusMap = {
|
||||||
|
|
Loading…
Reference in New Issue