Commit ef570214 authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

записи реестра - добавлена проверка прав на фильтры

parent f9ef354b
......@@ -262,7 +262,7 @@ const registryTable = {
openDocument: function(dataRow, updateData = false) {
Cons.setAppStore({dataRow: dataRow});
if(this.allRights.indexOf('rr_read') !== -1) {
if(this.allRights.includes('rr_read') || this.allRights.includes('rr_edit')) {
if(updateData) {
openFormPlayer(dataRow.dataUUID, null, () => {
this.createBody();
......@@ -370,6 +370,10 @@ const registryTable = {
},
createBody: function() {
try {
this.updateRigths();
if(!this.allRights.includes("rr_list")) throw new Error(`Нет прав на просмотр данного реестра`);
rest.synergyGet(this.getUrl(), data => {
this.tBody.empty();
if(data.errorCode && data.errorCode != 0) {
......@@ -382,6 +386,10 @@ const registryTable = {
Paginator.update();
tableContainer.scrollTop(0);
});
} catch (err) {
console.log('ERROR registryList createBody', err);
showMessage(err.message, 'error');
}
},
resetHeaderLabel: function(){
......@@ -553,11 +561,27 @@ const registryTable = {
}
},
updateRigths: function(){
if(this.filterCode) {
const selectFilter = this.registryFilters.find(x => x.code == this.filterCode);
if(selectFilter) {
this.allRights = [...selectFilter.rights];
} else {
this.allRights = [];
}
} else {
this.allRights = [...this.registryRights];
}
},
init: async function(params){
try {
this.reset();
const registryList = await getRegistryList();
const info = await appAPI.getRegistryInfo(params.registryCode);
if(!info || (info.hasOwnProperty('rights') && info.rights == "no")) throw new Error(`Нет прав на просмотр данного реестра`);
this.registryInfo = info;
this.heads = info.columns.filter(item => item.visible != '0')
.sort((a, b) => {
......@@ -571,9 +595,12 @@ const registryTable = {
this.registryID = info.registryID;
this.registryName = info.name;
this.registryCode = params.registryCode;
this.allRights = registryList.find(x => x.registryCode == this.registryCode).rights;
this.registryRights = registryList.find(x => x.registryCode == this.registryCode).rights;
this.registryFilters = await appAPI.getRegistryFilters(this.registryCode);
this.formCode = info.formCode;
if(this.registryFilters && this.registryFilters.hasOwnProperty('errorCode') && this.registryFilters.errorCode != 0) throw new Error(this.registryFilters.errorMessage);
if(params.filterCode) this.filterCode = params.filterCode;
if(params.searchString) this.searchString = params.searchString;
......@@ -584,8 +611,16 @@ const registryTable = {
fire({type: 'change_label', text: localizedText('0', '0', '0', '0')}, this.sum.resultLabel);
}
this.updateRigths();
if(!this.allRights.includes("rr_list")) throw new Error(`Нет прав на просмотр данного реестра`);
this.createHeader();
Paginator.init();
} catch (err) {
Cons.hideLoader();
console.log('ERROR init registry list', err);
showMessage(err.message, 'error');
}
}
}
......@@ -598,13 +633,9 @@ compContainer.off()
if(!registryTable.registryCode) return;
if(Paginator.currentPage != 1) return;
if(e.hasOwnProperty('eventParam')) {
let param = e.eventParam;
if(param.hasOwnProperty('filterCode')) {
registryTable.filterCode = param.filterCode;
}
if(e.eventParam.hasOwnProperty('filterSearchUrl')) {
registryTable.filterSearchUrl = null;
}
const {filterCode = null, filterSearchUrl = null} = e.eventParam;
if(filterCode) registryTable.filterCode = filterCode;
if(filterSearchUrl) registryTable.filterSearchUrl = filterSearchUrl;
}
Paginator.currentPage = 1;
registryTable.createBody();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment