This commit is contained in:
2020-07-27 21:52:00 +00:00
parent 14bf31b841
commit d5964f8d14
2 changed files with 23 additions and 7 deletions

View File

@@ -10,7 +10,7 @@
<gz-pick-list
:ayaType="ayaTypes().User"
:showEditIcon="false"
v-model="userId"
v-model="pickListSelectedUserId"
:label="$ay.t('UserList')"
ref="userPickList"
@input="checkSave()"
@@ -102,7 +102,7 @@ export default {
components: {},
data() {
return {
userId: null,
pickListSelectedUserId: null,
items: [],
toUsers: [],
message: null,
@@ -147,7 +147,9 @@ export default {
methods: {
checkSave() {
let hasSelection =
this.toUsers.length > 0 || (this.userId != null && this.userId != 0);
this.toUsers.length > 0 ||
(this.pickListSelectedUserId != null &&
this.pickListSelectedUserId != 0);
let hasText = this.message != null && this.message != "";
this.formState.dirty = hasSelection && hasText;
@@ -177,7 +179,7 @@ export default {
}
this.toUsers.push(selected);
this.userId = 0;
this.pickListSelectedUserId = 0;
this.checkSave();
},
ayaTypes: function() {
@@ -194,12 +196,24 @@ export default {
vm.formState.loading = true;
//always submit from this form for the current logged in user id
let url = API_BASE_URL;
let url = "notify/direct-message";
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
try {
let res = await window.$gz.api.upsert(url, vm.obj);
let userIdList = [];
if (vm.toUsers.length > 0) {
vm.toUsers.forEach(z => {
userIdList.push(z.id);
});
} else {
//just accept the single userid in the pickLkist
userIdList.push(vm.pickListSelectedUserId);
}
let res = await window.$gz.api.upsert(url, {
users: userIdList,
message: this.message
});
if (res.error) {
vm.formState.serverError = res.error;

View File

@@ -422,6 +422,7 @@ export default {
vm.formState.loading = false;
} else {
vm.obj = res.data;
//modify the menu as necessary
generateMenu(vm);
@@ -430,7 +431,8 @@ export default {
vm: vm,
dirty: false,
valid: true,
loading: false
loading: false,
readOnly: res.data.eventType == 27 && res.data.deliveryMethod == 1 //default in-app notification is read only
});
}
} catch (error) {