re-factor / cleanup

This commit is contained in:
2022-01-11 22:08:38 +00:00
parent e871708b20
commit e0be8a7cfe
251 changed files with 14680 additions and 15693 deletions

View File

@@ -7,12 +7,12 @@
<v-row>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-text-field
ref="name"
v-model="obj.name"
:readonly="formState.readOnly"
:label="$ay.t('TaskGroupName')"
:rules="[form().required(this, 'name')]"
:error-messages="form().serverErrors(this, 'name')"
ref="name"
data-cy="name"
@input="fieldValueChanged('name')"
></v-text-field>
@@ -20,10 +20,10 @@
<v-col cols="12" sm="6" lg="4" xl="3">
<v-checkbox
ref="active"
v-model="obj.active"
:readonly="formState.readOnly"
:label="$ay.t('Active')"
ref="active"
data-cy="active"
:error-messages="form().serverErrors(this, 'active')"
@change="fieldValueChanged('active')"
@@ -68,8 +68,8 @@
v-if="!formState.readOnly"
large
icon
@click="editItem(item.index)"
class="ml-4"
@click="editItem(item.index)"
>
<v-icon small>
$ayiEdit
@@ -84,14 +84,14 @@
<!------------------------------------->
<v-col cols="12">
<v-textarea
ref="notes"
v-model="obj.notes"
:readonly="formState.readOnly"
:label="$ay.t('TaskGroupNotes')"
:error-messages="form().serverErrors(this, 'notes')"
ref="notes"
data-cy="notes"
@input="fieldValueChanged('notes')"
auto-grow
@input="fieldValueChanged('notes')"
></v-textarea>
</v-col>
</v-row>
@@ -112,25 +112,25 @@
<v-row>
<v-col cols="12">
<v-textarea
ref="task"
v-model="obj.items[editItemIndex].task"
:readonly="formState.readOnly"
:label="$ay.t('Task')"
:error-messages="
form().serverErrors(this, `Items[${editItemIndex}].task`)
"
@input="fieldValueChanged(`Items[${editItemIndex}].task`)"
ref="task"
data-cy="task"
auto-grow
@input="fieldValueChanged(`Items[${editItemIndex}].task`)"
></v-textarea>
</v-col>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-text-field
ref="Items.sequence"
v-model="obj.items[editItemIndex].sequence"
:readonly="formState.readOnly"
:label="$ay.t('Sequence')"
ref="Items.sequence"
data-cy="Items.sequence"
:rules="[
form().integerValid(this, 'Items.sequence'),
@@ -142,10 +142,10 @@
`Items[${editItemIndex}].sequence`
)
"
type="number"
@input="
fieldValueChanged(`Items[${editItemIndex}].sequence`)
"
type="number"
></v-text-field>
</v-col>
</v-row>
@@ -160,16 +160,16 @@
<v-btn
color="blue darken-1"
text
@click="addItem()"
class="ml-4"
@click="addItem()"
>{{ $ay.t("New") }}</v-btn
>
<v-btn
color="blue darken-1"
text
@click="editItemDialog = false"
class="ml-4"
@click="editItemDialog = false"
>{{ $ay.t("OK") }}</v-btn
>
</template>
@@ -214,6 +214,77 @@
const FORM_KEY = "svc-task-group-edit";
const API_BASE_URL = "task-group/";
export default {
data() {
return {
obj: {
id: 0,
concurrency: 0,
name: null,
active: true,
notes: null,
items: []
},
formState: {
ready: false,
dirty: false,
valid: true,
readOnly: false,
loading: true,
errorBoxMessage: null,
appError: null,
serverError: {}
},
rights: window.$gz.role.defaultRightsObject(),
ayaType: window.$gz.type.TaskGroup,
selectedItem: null,
editItemDialog: false,
editItemIndex: 0
};
},
computed: {
itemList: function() {
return this.obj.items
.map((x, i) => {
return {
index: i,
id: x.id,
sequence: x.sequence,
task: x.task
};
})
.sort((a, b) => a.sequence - b.sequence);
}
},
watch: {
formState: {
handler: function(val) {
if (this.formState.loading) {
return;
}
if (val.dirty && val.valid && !val.readOnly) {
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
} else {
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
}
if (!val.dirty && val.valid && !val.readOnly) {
window.$gz.eventBus.$emit(
"menu-enable-item",
FORM_KEY + ":duplicate"
);
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":new");
} else {
window.$gz.eventBus.$emit(
"menu-disable-item",
FORM_KEY + ":duplicate"
);
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":new");
}
},
deep: true
}
},
async created() {
const vm = this;
try {
@@ -269,63 +340,6 @@ export default {
beforeDestroy() {
window.$gz.eventBus.$off("menu-click", clickHandler);
},
data() {
return {
obj: {
id: 0,
concurrency: 0,
name: null,
active: true,
notes: null,
items: []
},
formState: {
ready: false,
dirty: false,
valid: true,
readOnly: false,
loading: true,
errorBoxMessage: null,
appError: null,
serverError: {}
},
rights: window.$gz.role.defaultRightsObject(),
ayaType: window.$gz.type.TaskGroup,
selectedItem: null,
editItemDialog: false,
editItemIndex: 0
};
},
watch: {
formState: {
handler: function(val) {
if (this.formState.loading) {
return;
}
if (val.dirty && val.valid && !val.readOnly) {
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
} else {
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
}
if (!val.dirty && val.valid && !val.readOnly) {
window.$gz.eventBus.$emit(
"menu-enable-item",
FORM_KEY + ":duplicate"
);
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":new");
} else {
window.$gz.eventBus.$emit(
"menu-disable-item",
FORM_KEY + ":duplicate"
);
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":new");
}
},
deep: true
}
},
methods: {
addItem: function() {
const newIndex = this.obj.items.length;
@@ -498,20 +512,6 @@ export default {
});
}
}
},
computed: {
itemList: function() {
return this.obj.items
.map((x, i) => {
return {
index: i,
id: x.id,
sequence: x.sequence,
task: x.task
};
})
.sort((a, b) => a.sequence - b.sequence);
}
}
};
@@ -537,17 +537,19 @@ async function clickHandler(menuItem) {
});
break;
case "report":
const res = await m.vm.$refs.reportSelector.open(
{
AType: window.$gz.type.TaskGroup,
selectedRowIds: [m.vm.obj.id]
},
m.id
);
if (res == null) {
return;
{
const res = await m.vm.$refs.reportSelector.open(
{
AType: window.$gz.type.TaskGroup,
selectedRowIds: [m.vm.obj.id]
},
m.id
);
if (res == null) {
return;
}
window.$gz.form.setLastReportMenuItem(FORM_KEY, res, m.vm);
}
window.$gz.form.setLastReportMenuItem(FORM_KEY, res, m.vm);
break;
default:
window.$gz.eventBus.$emit(
@@ -637,7 +639,7 @@ let JUST_DELETED = false;
/////////////////////////////////
//
//
async function initForm(vm) {
async function initForm() {
await fetchTranslatedText();
}