Benutzer, Ticketzuweißungen
This commit is contained in:
@@ -71,9 +71,24 @@ function showEditMode() {
|
||||
}
|
||||
|
||||
async function viewMachineDetail(id, options = {}) {
|
||||
const { startInEditMode = false } = options;
|
||||
const { startInEditMode = false, canEdit = true } = options;
|
||||
const m = await apiGet(`/machines/${id}`);
|
||||
|
||||
const btnEdit = document.getElementById('btn-m-edit');
|
||||
const btnDup = document.getElementById('btn-m-dup');
|
||||
const btnDel = document.getElementById('btn-m-del');
|
||||
const btnDelEdit = document.getElementById('btn-m-del-edit');
|
||||
if (!canEdit) {
|
||||
btnEdit.hidden = true;
|
||||
btnDup.hidden = true;
|
||||
btnDel.hidden = true;
|
||||
btnDelEdit.hidden = true;
|
||||
document.getElementById('machine-extras-edit').innerHTML = '';
|
||||
fillView(m);
|
||||
showViewMode();
|
||||
return;
|
||||
}
|
||||
|
||||
fillView(m);
|
||||
if (startInEditMode) {
|
||||
fillEdit(m);
|
||||
@@ -143,10 +158,11 @@ async function viewMachineDetail(id, options = {}) {
|
||||
async function init() {
|
||||
const st = await guard({ activeNav: 'machines' });
|
||||
if (!st) return;
|
||||
const canEdit = st.user?.canEditCrm === true;
|
||||
|
||||
const params = new URLSearchParams(location.search);
|
||||
const id = params.get('id');
|
||||
const startInEditMode = params.get('edit') === '1';
|
||||
const startInEditMode = canEdit && params.get('edit') === '1';
|
||||
if (!id || !UUID.test(id)) {
|
||||
loadingEl.hidden = true;
|
||||
badIdEl.hidden = false;
|
||||
@@ -157,8 +173,10 @@ async function init() {
|
||||
mainEl.hidden = false;
|
||||
|
||||
try {
|
||||
await viewMachineDetail(id, { startInEditMode });
|
||||
if (startInEditMode) {
|
||||
await viewMachineDetail(id, { startInEditMode, canEdit });
|
||||
if (!canEdit && params.get('edit') === '1') {
|
||||
history.replaceState(null, '', `/machine.html?id=${encodeURIComponent(id)}`);
|
||||
} else if (startInEditMode) {
|
||||
history.replaceState(null, '', `/machine.html?id=${encodeURIComponent(id)}`);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user