Задача:
Разделение права доступа на записи в справочнике Валют
Вводная:
Есть много офисов компании, например Московскому офису совершенно не интересно каждый раз выбирать валюту UAH, DKK и.т.д. следовательно логично разграничить доступ на валюты
Решение:
1. tbl_Currency -> поставить галочку Is Administrated By Records
2. wnd_CurrencyDictionary
a) Добавить pgAccessDetail
б) wndAccessDetail -> Window = wnd_AccessGridArea
в) Pages -> определить событие PagesOnChangeActivePage
3.wnd_CurrencyDictionaryScript
a) Use Scripts -> scr_WorkspaceUtils
Код самого скрипта нужно поменять следующим образом :
//------------------------------------------------------------------------------
// wnd_CurrencyDictionaryScript
//------------------------------------------------------------------------------
var CurrencyDictionary = new Object();
var BaseWorkspace = new Object();
function InitializeGridData() {
CurrencyDictionary.CurrencyWindow = wndCurrency.Window;
CurrencyDictionary.CurrencyWindow.Prepare();
}
function InitializeCurrencyRateDetail() {
CurrencyDictionary.CurrencyRateWindow = wndCurrencyRateDetail.Window;
CurrencyDictionary.CurrencyRateWindow.Prepare();
}
function InitializeGlobalVariables() {
CurrencyDictionary.CurrencyDataset = GetDatasetFromWindow(
CurrencyDictionary.CurrencyWindow, DefDatasetLinkName);
CurrencyDictionary.CurrencyRateDataset = GetDatasetFromWindow(
CurrencyDictionary.CurrencyRateWindow, DefDatasetLinkName);
}
function InitializeGlobalDatalinks() {
dlCurrency.Dataset = CurrencyDictionary.CurrencyDataset;
dlCurrencyRate.Dataset = CurrencyDictionary.CurrencyRateDataset;
}
function OpenCurrencyDataset() {
CurrencyDictionary.CurrencyDataset.Open();
}
function Initialize(Window) {
InitializeGridData();
InitializeCurrencyRateDetail();
InitializeGlobalVariables();
InitializeGlobalDatalinks();
OpenCurrencyDataset();
}
function RefreshCurrencyRate() {
CurrencyDictionary.CurrencyDataset.Open();
var CurrencyID = CurrencyDictionary.CurrencyDataset.Values('ID');
if (CurrencyID == null) {
return;
}
SetAttribute(CurrencyDictionary.CurrencyRateWindow, 'ParentItemID',
CurrencyID);
RefreshDetailData(CurrencyDictionary.CurrencyDataset, 'ID',
CurrencyDictionary.CurrencyRateDataset, 'CurrencyID');
}
// ----------------------------------------------------------------------------
// Event handlers
// ----------------------------------------------------------------------------
function wnd_CurrencyDictionaryOnPrepare(Window) {
Initialize(Window);
}
function dlCurrencyOnDatasetAfterOpen(Dataset) {
// RefreshCurrencyRate();
RefreshDetails()
}
function dlCurrencyOnDatasetAfterPositionChange(Dataset) {
// RefreshCurrencyRate();
RefreshDetails()
}
function dlCurrencyOnDatasetRefreshRecord(Dataset, KeyValue, AddNewRecordOnPage) {
if (AddNewRecordOnPage) {
// RefreshCurrencyRate();
RefreshDetails()
}
}
function wnd_CurrencyDictionaryOnNotify(ScriptableService, Sender, Message, Data) {
if (Message == MSG_CLOSE) {
CloseWindow(Self);
}
}
function PagesOnChangeActivePage(Pages) {
RefreshDetails();
}
function RefreshDetails() {
if (Pages.ActivePage.Name == pgCurrencyRate.Name) {
RefreshCurrencyRate();
} else
if (Pages.ActivePage.Name == pgAccessDetail.Name) {
//26.06 Create BaseWorkspace
var Grid = wndCurrency.Window.ComponentsByName('grdData');
BaseWorkspace.GridDataset = CurrencyDictionary.CurrencyDataset;
BaseWorkspace.Grid = Grid
RefreshAccessDetail(BaseWorkspace, wndAccessDetail, 'tbl_CurrencyRight');
}
}