Skip to content

Commit

Permalink
feature: in progress [WTEL-4195]
Browse files Browse the repository at this point in the history
  • Loading branch information
lizacoma committed Feb 23, 2024
1 parent 8b451d6 commit e5b7e05
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 24 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"vue-router": "^4.2.5",
"vue2-dropzone": "^3.6.0",
"vuex": "^4.1.0",
"webitel-sdk": "^23.12.18"
"webitel-sdk": "^23.12.24"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.4.0",
Expand Down
5 changes: 4 additions & 1 deletion src/app/mixins/baseMixins/baseObjectMixin/baseObjectMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export default {
},

disabledSave() {
console.log('this.checkValidations():', this.checkValidations());
console.log('this.checkValidations():', this.checkValidations(),
'this.itemInstance._dirty:', this.itemInstance._dirty,
'!this.itemInstance._dirty && !!this.id:', !this.itemInstance._dirty && !!this.id,
'itemInstance:', this.itemInstance);
// if there's a validation problem
// OR it's edit and any fields haven't changed
return this.checkValidations() ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
import applyTransform, {
camelToSnake,
merge,
mergeEach,
notify,
sanitize,
snakeToCamel,
Expand Down Expand Up @@ -68,7 +67,6 @@ const get = async ({ itemId: id }) => {
const fieldsToSend = ['id', 'name', 'value', 'encrypt'];

const add = async ({itemInstance}) => {
console.log('add API:', itemInstance)
const item = applyTransform(itemInstance, [
sanitize(fieldsToSend),
camelToSnake(),
Expand All @@ -86,12 +84,10 @@ const add = async ({itemInstance}) => {
};

const update = async ({ itemInstance, itemId: id }) => {
console.log('update API id:', id, 'itemInstance:', itemInstance);
const item = applyTransform(itemInstance, [
sanitize(fieldsToSend),
camelToSnake(),
]);
console.log('update API item:', item);
try {
const response = await service.updateSchemaVariable(id, item);
return applyTransform(response.data, [
Expand All @@ -104,8 +100,24 @@ const update = async ({ itemInstance, itemId: id }) => {
}
};

const patch = async ({ id, changes }) => {
const body = applyTransform(changes, [
sanitize(fieldsToSend),
camelToSnake(),
]);
try {
const response = await service.patchSchemaVariable(id, body);
return applyTransform(response.data, [
snakeToCamel(),
]);
} catch (err) {
throw applyTransform(err, [
notify,
]);
}
};

const deleteItem = async ({ id }) => {
console.log('deleteItem id:', id);
try {
const response = await service.deleteSchemaVariable(id);
return applyTransform(response.data, []);
Expand All @@ -127,6 +139,7 @@ const GlobalVariablesAPI = {
get,
add,
update,
patch,
delete: deleteItem,
getLookup,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
:label="$t('objects.key')"
required
/>
isSwitcherOn: {{ isSwitcherOn }} inputType: {{ inputType }}
<wt-input
v-model="itemInstance.value"
:v="v$.itemInstance.value"
Expand Down Expand Up @@ -78,19 +77,18 @@ export default {
}),
validations: {
itemInstance: {
name: { required },
name: { required, $autoDirty: true },
value: {
required: requiredIf((value, item) => !item.id),
$autoDirty: true
},
encrypt: { $autoDirty: true }
},
},
computed: {
// isSwitcherOn() {
// return (this.id && this.itemInstance.encrypt);
// }
},
computed: {},
methods: {
async save() {
if (!this.disabledSave) {
if (this.id) {
await this.updateItem();
} else {
Expand All @@ -101,6 +99,7 @@ export default {
}
}
this.close();
}
},
async loadPageData() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
{{ item.name }}
</template>
<template #value="{ item }">
{{ item.value || '*************' }}
{{ item.encrypt ? '*************' : item.value }}
</template>
<template #encrypt="{ item, index }">
<wt-switcher
:value="item.encrypt"
:disabled="item.encrypt"
@change="updateItem({ ...item, encrypt: $event })"
@change="patchItem({ item, index, prop: 'encrypt', value: $event })"
/>
</template>
<template #actions="{ item }">
Expand Down Expand Up @@ -171,7 +171,6 @@ export default {
data: () => ({
namespace,
isGlobalVariablesPopup: false,
// editedItem: null,
}),
computed: {
...mapState({
Expand Down

0 comments on commit e5b7e05

Please sign in to comment.