This commit is contained in:
@@ -19,311 +19,387 @@ export default {
|
||||
}
|
||||
|
||||
if (tid.type && tid.id != null) {
|
||||
let isCustomerTypeUser =
|
||||
window.$gz.store.state.userType == 3 ||
|
||||
window.$gz.store.state.userType == 4;
|
||||
//if these come from route parameters they may well be strings
|
||||
tid.type = Number.parseInt(tid.type, 10);
|
||||
tid.id = Number.parseInt(tid.id, 10);
|
||||
switch (tid.type) {
|
||||
case ayatype.WorkOrder:
|
||||
vm.$router.push({
|
||||
name: "workorder-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Memo:
|
||||
vm.$router.push({
|
||||
name: "memo-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Customer:
|
||||
vm.$router.push({
|
||||
name: "customer-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.CustomerNote:
|
||||
vm.$router.push({
|
||||
name: "customer-note-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.HeadOffice:
|
||||
vm.$router.push({
|
||||
name: "head-office-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Vendor:
|
||||
vm.$router.push({
|
||||
name: "vendor-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Widget:
|
||||
vm.$router.push({
|
||||
name: "widget-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.User:
|
||||
//Is it an "Inside" user (staff or subcontractor)
|
||||
//or an "outside" user (customer or headoffice)
|
||||
//if key doesn't provide this then need to directly find out first before determining which form to redirect to
|
||||
if (tid.id != 0) {
|
||||
//lookup which one to open from server
|
||||
if (isCustomerTypeUser) {
|
||||
switch (tid.type) {
|
||||
case ayatype.WorkOrder:
|
||||
vm.$router.push({
|
||||
name: "customer-workorder-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
|
||||
case ayatype.NotifySubscription:
|
||||
vm.$router.push({
|
||||
name: "home-notify-subscription",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.CustomerServiceRequest:
|
||||
vm.$router.push({
|
||||
name: "customer-csr-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
default:
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-warning",
|
||||
`Customer user: open-object-handler unable to open link - [type:${tid.type}, id:${tid.id}]`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
switch (tid.type) {
|
||||
case ayatype.WorkOrderItem:
|
||||
case ayatype.WorkOrderItemExpense:
|
||||
case ayatype.WorkOrderItemLabor:
|
||||
case ayatype.WorkOrderItemLoan:
|
||||
case ayatype.WorkOrderItemOutsideService:
|
||||
case ayatype.WorkOrderItemPart:
|
||||
case ayatype.WorkOrderItemPartRequest:
|
||||
case ayatype.WorkOrderItemScheduledUser:
|
||||
case ayatype.WorkOrderItemTask:
|
||||
case ayatype.WorkOrderItemTravel:
|
||||
case ayatype.WorkOrderItemUnit:
|
||||
(async () => {
|
||||
try {
|
||||
//shortcut for superuser, always id 1
|
||||
if (tid.inside == undefined && tid.id == 1) {
|
||||
tid.inside = true;
|
||||
}
|
||||
if (tid.inside == undefined) {
|
||||
let res = await window.$gz.api.get(
|
||||
"user/inside-type/" + tid.id
|
||||
let res = await window.$gz.api.get(
|
||||
`search/ancestor/${tid.type}/${tid.id}`
|
||||
);
|
||||
|
||||
if (res.error) {
|
||||
throw new Error(
|
||||
window.$gz.errorHandler.errorToString(res, vm)
|
||||
);
|
||||
if (res.error) {
|
||||
//throw new Error(res.error);
|
||||
throw new Error(
|
||||
window.$gz.errorHandler.errorToString(res, vm)
|
||||
);
|
||||
}
|
||||
if (res.data) {
|
||||
tid.inside = res.data;
|
||||
}
|
||||
}
|
||||
if (tid.inside == true) {
|
||||
vm.$router.push({
|
||||
name: "adm-user",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
} else {
|
||||
vm.$router.push({
|
||||
name: "cust-user",
|
||||
params: { recordid: tid.id }
|
||||
if (res.data.id && res.data.id != 0) {
|
||||
this.handleOpenObjectClick(vm, {
|
||||
type: ayatype.WorkOrder,
|
||||
id: res.data.id,
|
||||
gotype: tid.type,
|
||||
goid: tid.id
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(window.$gz.errorHandler.errorToString(e, vm));
|
||||
//throw new Error(e);
|
||||
throw new Error(window.$gz.errorHandler.errorToString(e, vm));
|
||||
}
|
||||
})();
|
||||
}
|
||||
break;
|
||||
case ayatype.NotifySubscription:
|
||||
vm.$router.push({
|
||||
name: "home-notify-subscription",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.FileAttachment:
|
||||
//lookup the actual type
|
||||
//then call this method again to do the actual open
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
let res = await window.$gz.api.get("attachment/parent/" + tid.id);
|
||||
|
||||
if (res.error) {
|
||||
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
|
||||
// throw new Error(res.error);
|
||||
}
|
||||
if (res.data.id && res.data.id != 0) {
|
||||
this.handleOpenObjectClick(vm, res.data);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
//throw new Error(e);
|
||||
throw new Error(window.$gz.errorHandler.errorToString(e, vm));
|
||||
break;
|
||||
case ayatype.WorkOrder:
|
||||
vm.$router.push({
|
||||
name: "workorder-edit",
|
||||
params: { recordid: tid.id, gotype: tid.gotype, goid: tid.goid }
|
||||
});
|
||||
break;
|
||||
case ayatype.Memo:
|
||||
vm.$router.push({
|
||||
name: "memo-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Customer:
|
||||
vm.$router.push({
|
||||
name: "customer-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.CustomerNote:
|
||||
vm.$router.push({
|
||||
name: "customer-note-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.HeadOffice:
|
||||
vm.$router.push({
|
||||
name: "head-office-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Vendor:
|
||||
vm.$router.push({
|
||||
name: "vendor-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Widget:
|
||||
vm.$router.push({
|
||||
name: "widget-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.User:
|
||||
//Is it an "Inside" user (staff or subcontractor)
|
||||
//or an "outside" user (customer or headoffice)
|
||||
//if key doesn't provide this then need to directly find out first before determining which form to redirect to
|
||||
if (tid.id != 0) {
|
||||
//lookup which one to open from server
|
||||
(async () => {
|
||||
try {
|
||||
//shortcut for superuser, always id 1
|
||||
if (tid.inside == undefined && tid.id == 1) {
|
||||
tid.inside = true;
|
||||
}
|
||||
if (tid.inside == undefined) {
|
||||
let res = await window.$gz.api.get(
|
||||
"user/inside-type/" + tid.id
|
||||
);
|
||||
if (res.error) {
|
||||
//throw new Error(res.error);
|
||||
throw new Error(
|
||||
window.$gz.errorHandler.errorToString(res, vm)
|
||||
);
|
||||
}
|
||||
if (res.data) {
|
||||
tid.inside = res.data;
|
||||
}
|
||||
}
|
||||
if (tid.inside == true) {
|
||||
vm.$router.push({
|
||||
name: "adm-user",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
} else {
|
||||
vm.$router.push({
|
||||
name: "cust-user",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(window.$gz.errorHandler.errorToString(e, vm));
|
||||
//throw new Error(e);
|
||||
}
|
||||
})();
|
||||
}
|
||||
})();
|
||||
break;
|
||||
case ayatype.NotifySubscription:
|
||||
vm.$router.push({
|
||||
name: "home-notify-subscription",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.FileAttachment:
|
||||
//lookup the actual type
|
||||
//then call this method again to do the actual open
|
||||
|
||||
//error here? or do nothing, doing nothing for now, should only apply if it's an orphan record and that is kind of obvious
|
||||
//or error "Can't open nothing"
|
||||
break;
|
||||
//TODO: Items that are able to be opened from the adm-history form
|
||||
//need to decide to support them and if not then need to modify the message below
|
||||
//to be localized and simply say "Can't open this object type" or something along those lines
|
||||
//TODO: FORMCUSTOMIZATION
|
||||
//TODO: LIST VIEW
|
||||
case ayatype.Translation:
|
||||
vm.$router.push({
|
||||
name: "adm-translation",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Report:
|
||||
vm.$router.push({
|
||||
name: "ay-report-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Backup:
|
||||
vm.$router.push({
|
||||
name: "ops-backup"
|
||||
});
|
||||
break;
|
||||
(async () => {
|
||||
try {
|
||||
let res = await window.$gz.api.get(
|
||||
"attachment/parent/" + tid.id
|
||||
);
|
||||
|
||||
case ayatype.FormCustom:
|
||||
//all we have is the id, but need the formkey to open it
|
||||
(async () => {
|
||||
try {
|
||||
let res = await window.$gz.api.get(
|
||||
"form-custom/form-key/" + tid.id
|
||||
);
|
||||
|
||||
if (res.error) {
|
||||
//throw new Error(res.error);
|
||||
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
|
||||
if (res.error) {
|
||||
throw new Error(
|
||||
window.$gz.errorHandler.errorToString(res, vm)
|
||||
);
|
||||
// throw new Error(res.error);
|
||||
}
|
||||
if (res.data.id && res.data.id != 0) {
|
||||
this.handleOpenObjectClick(vm, res.data);
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
//throw new Error(e);
|
||||
throw new Error(window.$gz.errorHandler.errorToString(e, vm));
|
||||
}
|
||||
if (res && res.data) {
|
||||
vm.$router.push({
|
||||
name: "ay-customize",
|
||||
params: { formCustomTemplateKey: res.data }
|
||||
});
|
||||
return;
|
||||
})();
|
||||
|
||||
//error here? or do nothing, doing nothing for now, should only apply if it's an orphan record and that is kind of obvious
|
||||
//or error "Can't open nothing"
|
||||
break;
|
||||
//TODO: Items that are able to be opened from the adm-history form
|
||||
//need to decide to support them and if not then need to modify the message below
|
||||
//to be localized and simply say "Can't open this object type" or something along those lines
|
||||
//TODO: FORMCUSTOMIZATION
|
||||
//TODO: LIST VIEW
|
||||
case ayatype.Translation:
|
||||
vm.$router.push({
|
||||
name: "adm-translation",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Report:
|
||||
vm.$router.push({
|
||||
name: "ay-report-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Backup:
|
||||
vm.$router.push({
|
||||
name: "ops-backup"
|
||||
});
|
||||
break;
|
||||
|
||||
case ayatype.FormCustom:
|
||||
//all we have is the id, but need the formkey to open it
|
||||
(async () => {
|
||||
try {
|
||||
let res = await window.$gz.api.get(
|
||||
"form-custom/form-key/" + tid.id
|
||||
);
|
||||
|
||||
if (res.error) {
|
||||
//throw new Error(res.error);
|
||||
throw new Error(
|
||||
window.$gz.errorHandler.errorToString(res, vm)
|
||||
);
|
||||
}
|
||||
if (res && res.data) {
|
||||
vm.$router.push({
|
||||
name: "ay-customize",
|
||||
params: { formCustomTemplateKey: res.data }
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
//throw new Error(e);
|
||||
throw new Error(window.$gz.errorHandler.errorToString(e, vm));
|
||||
}
|
||||
} catch (e) {
|
||||
//throw new Error(e);
|
||||
throw new Error(window.$gz.errorHandler.errorToString(e, vm));
|
||||
}
|
||||
})();
|
||||
break;
|
||||
case ayatype.Project:
|
||||
vm.$router.push({
|
||||
name: "project-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Reminder:
|
||||
vm.$router.push({
|
||||
name: "reminder-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Review:
|
||||
vm.$router.push({
|
||||
name: "review-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.ServiceRate:
|
||||
vm.$router.push({
|
||||
name: "service-rate-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.TravelRate:
|
||||
vm.$router.push({
|
||||
name: "travel-rate-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.TaxCode:
|
||||
vm.$router.push({
|
||||
name: "tax-code-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.UnitModel:
|
||||
vm.$router.push({
|
||||
name: "unit-model-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Unit:
|
||||
vm.$router.push({
|
||||
name: "unit-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.LoanUnit:
|
||||
vm.$router.push({
|
||||
name: "loan-unit-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.CustomerServiceRequest:
|
||||
vm.$router.push({
|
||||
name: "csr-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Part:
|
||||
vm.$router.push({
|
||||
name: "inv-part",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.PartInventory:
|
||||
//this one's a little different, there is no way to edit a partinventory transaction
|
||||
//so it opens to the history of the one clicked so user can see who was responsible
|
||||
vm.$router.push({
|
||||
name: "ay-history",
|
||||
params: { ayatype: ayatype.PartInventory, recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.PartWarehouse:
|
||||
vm.$router.push({
|
||||
name: "inv-part-warehouse",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.PartAssembly:
|
||||
vm.$router.push({
|
||||
name: "part-assembly-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
// case ayatype.ServiceBank:
|
||||
// vm.$router.push({
|
||||
// name: "service-bank-edit",
|
||||
// params: { recordid: tid.id }
|
||||
// });
|
||||
// break;
|
||||
case ayatype.PurchaseOrder:
|
||||
vm.$router.push({
|
||||
name: "inv-purchase-order",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Contract:
|
||||
vm.$router.push({
|
||||
name: "contract-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.WorkOrderStatus:
|
||||
vm.$router.push({
|
||||
name: "svc-work-order-status-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
})();
|
||||
break;
|
||||
case ayatype.Project:
|
||||
vm.$router.push({
|
||||
name: "project-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Reminder:
|
||||
vm.$router.push({
|
||||
name: "reminder-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Review:
|
||||
vm.$router.push({
|
||||
name: "review-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.ServiceRate:
|
||||
vm.$router.push({
|
||||
name: "service-rate-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.TravelRate:
|
||||
vm.$router.push({
|
||||
name: "travel-rate-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.TaxCode:
|
||||
vm.$router.push({
|
||||
name: "tax-code-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.UnitModel:
|
||||
vm.$router.push({
|
||||
name: "unit-model-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Unit:
|
||||
vm.$router.push({
|
||||
name: "unit-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.LoanUnit:
|
||||
vm.$router.push({
|
||||
name: "loan-unit-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.CustomerServiceRequest:
|
||||
vm.$router.push({
|
||||
name: "csr-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Part:
|
||||
vm.$router.push({
|
||||
name: "inv-part",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.PartInventory:
|
||||
//this one's a little different, there is no way to edit a partinventory transaction
|
||||
//so it opens to the history of the one clicked so user can see who was responsible
|
||||
vm.$router.push({
|
||||
name: "ay-history",
|
||||
params: { ayatype: ayatype.PartInventory, recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.PartWarehouse:
|
||||
vm.$router.push({
|
||||
name: "inv-part-warehouse",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.PartAssembly:
|
||||
vm.$router.push({
|
||||
name: "part-assembly-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
// case ayatype.ServiceBank:
|
||||
// vm.$router.push({
|
||||
// name: "service-bank-edit",
|
||||
// params: { recordid: tid.id }
|
||||
// });
|
||||
// break;
|
||||
case ayatype.PurchaseOrder:
|
||||
vm.$router.push({
|
||||
name: "inv-purchase-order",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.Contract:
|
||||
vm.$router.push({
|
||||
name: "contract-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.WorkOrderStatus:
|
||||
vm.$router.push({
|
||||
name: "svc-work-order-status-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
|
||||
case ayatype.WorkOrderItemStatus:
|
||||
vm.$router.push({
|
||||
name: "svc-work-order-item-status-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.WorkOrderItemStatus:
|
||||
vm.$router.push({
|
||||
name: "svc-work-order-item-status-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
|
||||
case ayatype.WorkOrderItemPriority:
|
||||
vm.$router.push({
|
||||
name: "svc-work-order-item-priorities-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.TaskGroup:
|
||||
vm.$router.push({
|
||||
name: "svc-task-group",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.WorkOrderItemPriority:
|
||||
vm.$router.push({
|
||||
name: "svc-work-order-item-priorities-edit",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
case ayatype.TaskGroup:
|
||||
vm.$router.push({
|
||||
name: "svc-task-group",
|
||||
params: { recordid: tid.id }
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-warning",
|
||||
`open-object-handler: unknown [type:${tid.type}, id:${tid.id}]`
|
||||
);
|
||||
default:
|
||||
window.$gz.eventBus.$emit(
|
||||
"notify-warning",
|
||||
`open-object-handler: unknown [type:${tid.type}, id:${tid.id}]`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user