Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
synergy-components
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
synergy-components
Commits
49688b3c
Commit
49688b3c
authored
Mar 28, 2018
by
Sergey Antonovich
🇯🇵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multi-registry-chooser.conf
parent
6bdb1783
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1073 additions
and
0 deletions
+1073
-0
form-cmp/multi-registry-chooser.conf.xml
form-cmp/multi-registry-chooser.conf.xml
+1073
-0
No files found.
form-cmp/multi-registry-chooser.conf.xml
0 → 100644
View file @
49688b3c
<?xml version="1.0" encoding="utf-8"?>
<configuration
version=
"1"
date=
"2018-03-28 16:43:15"
synergyVersion=
"3.15"
>
<objects
version=
"1"
date=
"2018-03-28 16:43:15"
synergyVersion=
"3.15"
>
<customComponent
code=
"registry_chooser"
name=
"Мультивыбор записей реестра"
use_in_forms=
"true"
>
<javascript>
// Инструкция по использованию
// 1. добавить данный пользовательский компонент на форму
// 2. в поле код скрипта компонента прописать код реестра и позволять ли мульти выбор
// model.registryCode = 'playertestForm';
// model.multiple = true;
// Формат данных
// {id : "id",
// type : "custom",
// value : "значащее содержимое документов через запятую",
// keys : [массив выбранных идентификаторов],
// key : "первый идентификатор если он есть",
// valueID : "хэш fnv32 отсортированных по возрастанию идентификаторов скленных через пробел"}
//
//
AS.FORMS.hash = function(str, asString, seed){
/*jshint bitwise:false */
var i, l,
hval = (seed === undefined) ? 0x811c9dc5 : seed;
for (i = 0, l = str.length; i
<
l; i++) {
hval ^= str.charCodeAt(i);
hval += (hval
<<
1) + (hval
<<
4) + (hval
<<
7) + (hval
<<
8) + (hval
<<
24);
}
if( asString ){
// Convert to 8 digit hex string
return ("0000000" + (hval
>>>
0).toString(16)).substr(-8);
}
return hval
>>>
0;
};
// ИНициалиация модели
model.onOnce = function(event, name, handler){
if(!model.handlers){
model.handlers = {};
}
if(model.handlers[event+"_"+name]){
model.off(event, model.handlers[event+"_"+name]);
}
model.handlers[event+"_"+name] = handler;
model.on(event, handler);
}
if(!model.selectedDocuments) {
model.selectedDocuments = [];
model.textValue = "";
}
model.updateTextView = function () {
if(!model.registry) return;
model.selectedDocuments = [];
model.textValue = "";
if (!model.getSelectedIds() || model.getSelectedIds().length == 0) {
model.textValue = "";
model.asfDataId = null;
model.trigger(AS.FORMS.EVENT_TYPE.dataLoad, [model]);
return;
}
var asfDataPromises = [];
model.getSelectedIds().forEach(function(documentId){
asfDataPromises.push(AS.FORMS.ApiUtils.simpleAsyncGet('rest/api/formPlayer/getAsfDataUUID?documentID=' + documentId, null, "text"));
model.selectedDocuments.push({documentId : documentId});
});
jQuery.when.apply(jQuery, asfDataPromises)
.then(function(){
var docMeaningPromises = [];
for(var i=0; i
<
arguments.length; i++){
model.selectedDocuments[i].asfDataId = arguments[i];
docMeaningPromises.push(AS.FORMS.ApiUtils.simpleAsyncGet('rest/api/formPlayer/getDocMeaningContent?registryID=' + model.registry.registryID + "
&
asfDataUUID=" + arguments[i], null, "text"));
}
jQuery.when.apply(jQuery, docMeaningPromises).then(function(){
var sign = "";
for(var i=0; i
<
arguments.length; i++){
model.selectedDocuments[i].meaning = arguments[i];
if(model.selectedDocuments[i].meaning == '') {
model.selectedDocuments[i].meaning = i18n.tr('Документ');
}
model.textValue = model.textValue + sign + model.selectedDocuments[i].meaning;
sign = ", ";
}
model.trigger(AS.FORMS.EVENT_TYPE.dataLoad, [model]);
});
});
};
model.getTextValue = function () {
return model.textValue;
};
model.setAsfData = function (asfData) {
if(asfData.keys || asfData.key){
if(!asfData.keys) {
asfData.keys = [asfData.key];
}
model.setValue(asfData.keys);
} else {
model.setValue([]);
}
};
model.getSelectedIds = function(){
return model.value;
};
model.getValue = function(){
if(model.multiple) {
return model.value;
} else {
if(model.value.length ==0){
return null;
} else {
return model.value[0];
}
}
};
model.getAsfData = function (blockNumber) {
var valueID = "";
if(model.value) {
var array = model.value.slice().sort();
valueID = AS.FORMS.hash(array.join(" "));
}
var asfData = AS.FORMS.ASFDataUtils.getBaseAsfData(model.asfProperty, blockNumber, model.textValue, null);
asfData.keys = model.value;
if(asfData.keys
&&
asfData.keys.length
>
0) {
asfData.key = asfData.keys[0];
}
asfData.valueID = valueID;
return asfData;
};
model.onOnce(AS.FORMS.EVENT_TYPE.valueChange, "updateTextView", function () {
model.updateTextView();
});
// ИНициализация отображения
view.init = function() {
var tagArea = new AS.FORMS.TagArea({width: "calc(100% - 30px)"}, 0, model.multiple, false, false);
var chooserButton = jQuery("
<
div/
>
", {style: "border: 1px solid #e2e2e2; border-radius: 0 4px 4px 0; vertical-align: top;" +
"height: 28px; width: 30px; align-self: center; padding: 4px 0 0;cursor: pointer;display: inline-block; " +
"box-sizing: border-box; font-weight: bold; font-size: 20px; padding-left: 5px;"}).html("...");
var fileNameLabel = jQuery('
<
div
>
', {style: "font-family: arial, tahoma, sans-serif; font-size: 12px; align-self: center; word-wrap: break-word; padding-right: 2px; padding-left: 1px;"});
tagArea.on("tagDelete", function () {
var documentIds = [];
tagArea.getValues().forEach(function(tagItem){
documentIds.push(tagItem.documentId);
});
model.setValueFromInput(documentIds);
});
if (editable) {
var div = jQuery('
<
div
>
');
div.append(tagArea.getWidget());
div.append(chooserButton);
view.container.prepend(div);
} else {
view.container.prepend(fileNameLabel);
}
chooserButton.click(function(){
var selectedIds = [];
if(model.getSelectedIds()) {
selectedIds = model.getSelectedIds();
}
var chooser = new RegistryChooser(model.registry, model.multiple, model.filterIds, selectedIds, function(selected){
var documentIds = [];
selected.forEach(function(item){
documentIds.push(item.documentId);
});
model.setValueFromInput(documentIds);
});
chooser.show();
});
AS.FORMS.ApiUtils.simpleAsyncGet('rest/api/registry/info?code=' + model.registryCode, function (reg) {
model.registry = reg;
model.registry.registryID = reg.registryID;
model.updateTextView();
});
view.updateValueFromModel = function () {
fileNameLabel.html("");
tagArea.setValues([]);
if (model.getSelectedIds()
&&
model.getSelectedIds().length
>
0) {
model.selectedDocuments.forEach(function(selectedDocument){
selectedDocument.tagName = selectedDocument.meaning;
var docComponent = jQuery("
<
div
>
", {style : "font-family: arial, tahoma, sans-serif; font-size: 12px; " +
"align-self: center; word-wrap: break-word; padding-right: 2px;" +
"padding-left: 1px; cursor : pointer; text-decoration: underline;" +
"line-height:20px"}).html(selectedDocument.meaning);
docComponent.click(function(){
AS.SERVICES.showDocument(selectedDocument.documentId);
});
fileNameLabel.append(docComponent);
});
tagArea.setValues(model.selectedDocuments);
}
};
view.updateValueFromModel();
model.on("dataLoad", function () {
view.updateValueFromModel();
});
};
if(model.registryCode) {
view.init();
} else {
model.on("loadComponentAdditionalInfo", function(){
view.init();
});
}
var KEY_CODES = Object.freeze({
backspace : 8,
delete : 46,
insert : 45,
left : 37,
up : 38,
right : 39,
down : 40,
home : 36,
end : 35,
pageUp : 33,
pageDown : 34,
tab : 9,
MINUS : 189,
DOT: 190,
COMMA : 188,
ENTER : 13,
escape : 27,
Z_KEY : 90
});
// ТАБЛИЦА
var MultiTableEvent = {
dataClicked : "dataClicked",
dataSelected : "dataSelected",
dataDeselected : "dataDeselected",
columnSortClicked : "columnSortClicked",
inited : "inited",
colResized : "colResized",
colResizeStarted : "colResizeStarted",
dataLoaded : "dataLoaded"
};
var MultiTable = function(multiChoose, initialSelect) {
var instance = this;
instance.bus = jQuery({});
this.trigger = function (eventType, args) {
instance.bus.trigger(eventType, args);
};
this.on = function (eventType, handler) {
instance.bus.on(eventType, handler);
};
this.off = function (eventType, handler) {
instance.bus.off(eventType, handler);
};
var headerRowHeight = 32;
var rowHeight = 26;
var width = 500;
var headerRow = null;
var rows = [];
var container = jQuery("
<
div
>
", {style : "font-family: DroidSans, arial, serif;font-size: 14px;color: #606060; display: inline-block;text-align: left;", tabIndex : "0"});
var selectedData = [];
initialSelect.forEach(function(item){
selectedData.push(item);
});
var idField = "id";
var columns = [];
this.init = function(options, newColumns){
instance.clear();
headerRow = new MultiTableHeaderRow(instance, -1);
container.append(headerRow.getWidget());
columns = newColumns;
headerRowHeight = options["headerRowHeight"] || headerRowHeight;
rowHeight = options["rowHeight"] || rowHeight;
width = options["width"] || width;
idField = options["idField"] || idField;
instance.trigger(MultiTableEvent.inited, []);
};
instance.on(MultiTableEvent.dataClicked, function(evt, data){
if(multiChoose) {
if (!instance.isSelected(data)) {
selectedData.push(data);
instance.trigger(MultiTableEvent.dataSelected, data);
} else {
var index = -1;
selectedData.forEach(function(candidate, candidateIndex){
if(candidate[idField] == data[idField]) {
index = candidateIndex;
}
});
selectedData.splice(index, 1);
instance.trigger(MultiTableEvent.dataDeselected, data);
}
} else {
while(selectedData.length
>
0) {
var d = selectedData[0];
var i = selectedData.indexOf(d);
selectedData.splice(i, 1);
instance.trigger(MultiTableEvent.dataDeselected, d);
}
selectedData.push(data);
instance.trigger(MultiTableEvent.dataSelected, data);
}
container.focus();
});
this.isSelected = function(data) {
var selected = false;
selectedData.forEach(function(item){
if(item[idField] == data[idField]) {
selected = true;
}
});
return selected;
};
this.getSelectedData = function() {
return selectedData;
};
this.getColumns = function(){
return columns;
};
this.getHeaderRowHeight = function(){
return headerRowHeight;
};
this.getRowHeight = function(){
return rowHeight;
};
this.clear = function() {
container.empty();
};
this.setData = function(data, append) {
if(!append) {
rows.forEach(function(row){
row.getWidget().detach();
row.getWidget().empty();
});
rows = [];
}
var rowsCount = rows.length;
data.forEach(function(data, dataIndex){
var row = new MultiTableRow(instance, data, dataIndex+rowsCount);
rows.push(row);
container.append(row.getWidget());
});
instance.trigger(MultiTableEvent.dataLoaded, []);
};
this.setSelectedData = function(newSelectedData){
while(selectedData.length
>
0) {
var d = selectedData[0];
var i = selectedData.indexOf(d);
selectedData.splice(i, 1);
instance.trigger(MultiTableEvent.dataDeselected, d);
}
if(!newSelectedData) return;
newSelectedData.forEach(function(newSelectData){
selectedData.push(newSelectData);
instance.trigger(MultiTableEvent.dataSelected, newSelectData);
});
};
this.getWidget = function(){
return container;
};
};
var MultiTableHeaderRow = function(table, rowIndex) {
var headerRow = jQuery("
<
div
>
", {style : "border-bottom: 1px solid #d6d6d6;background: #fbfbfb;white-space: nowrap;"});
headerRow.css("height" , table.getHeaderRowHeight()+"px");
headerRow.css("line-height" , table.getHeaderRowHeight()+"px");
var cells = [];
table.on(MultiTableEvent.inited, function(){
cells = [];
headerRow.empty();
var columns = table.getColumns();
columns.forEach(function(column, columnIndex){
var headerCell = new MultiTableHeaderCell(table, column, columnIndex);
cells.push(headerCell);
headerRow.append(headerCell.getWidget());
});
});
this.getWidget = function() {
return headerRow;
};
var startX = -1;
var movingColumn = null;
var movingColumnIndex = -1;
table.on(MultiTableEvent.colResizeStarted, function(evt, screenX, columnIndex){
startX = screenX;
movingColumn = table.getColumns()[columnIndex];
movingColumnIndex = columnIndex;
});
headerRow.mousemove(function(evt){
if(!movingColumn) {
return;
}
var targetWidth = movingColumn.width - (startX - evt.screenX);
if(movingColumn.minWidth) {
targetWidth = Math.max(movingColumn.minWidth, targetWidth);
}
if(startX === -1) {
return;
}
movingColumn.width = targetWidth;
table.trigger(MultiTableEvent.colResized, [movingColumn, movingColumnIndex]);
startX = evt.screenX;
});
headerRow.mouseup(function(){
startX = -1;
movingColumn = null;
movingColumnIndex = -1;
});
headerRow.mouseout(function(){
startX = -1;
movingColumn = null;
movingColumnIndex = -1;
});
};
var MultiTableHeaderCell = function(table, columnOption, columnIndex) {
var header = jQuery("
<
div
>
", {style : "padding-left: 12px;display: inline-block;border-right: 1px solid #d6d6d6;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;height: 100%;box-sizing: border-box;", title : columnOption.name});
header.css("width", columnOption.width+"px");
var text = jQuery("
<
div
>
", {style : "display: inline-block;width: calc(100% - 12px);overflow: hidden;white-space: nowrap;text-overflow: ellipsis;height: 100%;"});
text.html(columnOption.name);
var movingAnchor = jQuery("
<
div
>
", {style : "cursor: ew-resize;width: 12px;height: 100%;display: inline-block;"});
var sortImage = jQuery("
<
div
>
", {style : "margin-left: 9px;margin-bottom: 9px;"});
sortImage.hide();
var sortAsc = null;
header.append(text);
header.append(sortImage);
header.append(movingAnchor);
this.getWidget = function() {
return header;
};
this.cancelEventDispatch = function(element, event){
element.on(event, function (evt) {
evt.cancelBubble = true;
evt.stopped = true;
evt.stopPropagation();
evt.preventDefault();
});
};
this.notMovingClick = function(element, handler) {
var moving = false;
element.mousedown(function () {
moving = false;
});
element.mousemove(function () {
moving = true;
});
element.mouseup(function () {
if (moving) {
return;
}
handler(arguments);
});
};
this.cancelEventDispatch(movingAnchor, 'mouseout');
this.cancelEventDispatch(header, 'mouseout');
this.cancelEventDispatch(text, 'mouseout');
/** resizing header **/
movingAnchor.mousedown(function(evt){
table.trigger(MultiTableEvent.colResizeStarted, [evt.screenX, columnIndex]);
evt.cancelBubble = true;
evt.stopped = true;
evt.stopPropagation();
});
table.on(MultiTableEvent.colResized, function(evt, column){
if(columnOption === column) {
header.css("width", columnOption.width+"px");
}
});
/** sorting header **/
if(columnOption.sortable) {
this.notMovingClick(header, function(){
sortAsc = !sortAsc;
table.trigger(MultiTableEvent.columnSortClicked, [columnIndex, sortAsc, columnOption]);
});
table.on(MultiTableEvent.columnSortClicked, function(event, columnIndex, sortAsc, column){
if(columnOption === column ) {
text.css("width", "calc(100% - 31px)");
sortImage.css("display", "inline-block");
if(sortAsc) {
sortImage.addClass("ns-tableSortDescIcon");
sortImage.removeClass("ns-tableSortAscIcon");
} else {
sortImage.removeClass("ns-tableSortDescIcon");
sortImage.addClass("ns-tableSortAscIcon");
}
} else {
text.css("width", "");
sortAsc = null;
sortImage.hide();
}
});
}
};
var MultiTableRow = function(table, data, rowIndex) {
var row = jQuery("
<
div
>
", {style : "border-bottom: 1px dotted #d6d6d6;white-space: nowrap;"});
if(rowIndex%2
>
0) {
row.css("background", "#fbfbfb");
}
row.css("height" , table.getRowHeight()+"px");
row.css("line-height" , table.getRowHeight()+"px");
var cells = [];
var columns = table.getColumns();
columns.forEach(function(column){
var cell = new MultiTableCell(column.width, data[column.id]);
cells.push(cell);
row.append(cell.getWidget());
});
var selected = false;
var hover = false;
this.validateBackground = function(){
if(selected) {
if(hover) {
row.css("background", "#e7e8b1");
} else {
row.css("background", "#deefff");
}
} else if (hover){
row.css("background", "#f5f5dc");
} else {
if (rowIndex % 2
>
0) {
row.css("background", "#fbfbfb");
} else {
row.css("background", "");
}
}
};
var instance = this;
table.on(MultiTableEvent.colResized, function(evt, column, columnIndex){
cells[columnIndex].setWidth(column.width);
});
row.click(function(){
table.trigger(MultiTableEvent.dataClicked, [data]);
});
table.on(MultiTableEvent.dataSelected, function(){
selected = table.isSelected(data);
instance.validateBackground();
});
table.on(MultiTableEvent.dataDeselected, function(){
selected = table.isSelected(data);
instance.validateBackground();
});
this.getWidget = function() {
return row;
};
selected = table.isSelected(data);
this.validateBackground(false, false);
};
var MultiTableCell = function(width, value) {
var cell = jQuery("
<
div
>
", {style : "padding-left: 12px; padding-right: 12px;display: inline-block; border-right: 1px dotted #d6d6d6; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 100%; box-sizing: border-box;", title : value});
cell.text(value);
this.getWidget = function() {
return cell;
};
this.setWidth = function(width) {
cell.css("width", width+"px");
};
this.setWidth(width);
};
// ТАБЛИЦА РЕЕСТРА
var RegistryTable = function(registry, multiChoose, filterIds, selectedData) {
var columns = [];
var recordsCount = 0;
var currentPage = 0;
var search = null;
var sortCmpId = null;
var sortAsc = null;
var countInPage = 15;
var instance = this;
this.filterID = null;
var width = 780;
registry.columns.forEach(function(col){
if(col.visible != 1) {
return;
}
col.id = col.columnID;
col.name = col.label;
columns.push(col);
});
var columnWidth = 150;
if(columns.length
<
= 5) {
columnWidth = (width - 1)/columns.length;
}
columns = columns.sort(function(item1, item2){
var number1 = item1.order;
var number2 = item2.order;
if(number1 === number2) {
if(item1.name
<
item2.name) {
return -1;
} else if(item1.name
>
item2.name) {
return 1;
}
} else {
if(number1 === 0 ) {
return 1;
} else if(number2 === 0 ) {
return -1;
} else if(number1
<
number2) {
return -1;
} else {
return 1;
}
}
return 0;
});
console.log(columns);
columns.forEach(function(column){
column.width = columnWidth;
column.minWidth = 35;
});
var table = new MultiTable(multiChoose, selectedData);
table.init({idField : 'documentId'}, columns);
this.dblclick = function(handler){
table.getWidget().dblclick(handler);
};
table.on(MultiTableEvent.columnSortClicked, function(event, columnIndex, sortAsc, columnOption){
instance.sort(columnOption.id, sortAsc);
});
this.addDataClicked = function(handler){
table.on(MultiTableEvent.dataClicked, handler);
};
this.search = function(newSearch) {
search = newSearch;
this.loadData(0, this.filterID);
};
this.sort = function(cmpId, asc){
sortCmpId = cmpId;
sortAsc = asc;
this.loadData(0, this.filterID);
};
this.parseData = function(data){
var registryData = [];
data.result.forEach(function (item) {
var mergedItem = item.fieldValue;
mergedItem.documentId = item.documentID;
mergedItem.asfDataId = item.dataUUID;
mergedItem.uuid = item.documentID;
registryData.push(mergedItem);
});
return registryData;
};
this.loadData = function(pageNumber){
currentPage = pageNumber;
var params = {
registryID: registry.registryID,
pageNumber: pageNumber,
countInPart: countInPage,
searchString: search,
sortCmpID: sortCmpId,
sortDesc: sortAsc
};
if(model.additionalParams) {
params = Object.assign(params, model.additionalParams);
}
if(filterIds){
params.pageNumber=0;
params.countInPart=0;
}
AS.SERVICES.showWaitWindow();
AS.FORMS.ApiUtils.simpleAsyncGet('rest/api/registry/data_ext?' + $.param(params), function(data){
data = instance.filterData(data, pageNumber);
recordsCount = data.recordsCount;
table.setData(instance.parseData(data));
AS.SERVICES.hideWaitWindow();
});
};
this.selectAll = function() {
if(!multiChoose ) return;
var params = {
registryID: registry.registryID,
pageNumber: 0,
countInPart: 0,
searchString: search,
sortCmpID: sortCmpId,
sortDesc: sortAsc
};
AS.SERVICES.showWaitWindow();
AS.FORMS.ApiUtils.simpleAsyncGet('rest/api/registry/data_ext?' + $.param(params), function(data){
data = instance.filterData(data, 0);
table.setSelectedData(instance.parseData(data));
AS.SERVICES.hideWaitWindow();
});
};
this.filterData = function(data, pageNumber){
if(!filterIds) return data;
var result = {recordsCount : 0, result : []};
var start = pageNumber*countInPage;
var finish = start+countInPage;
data.result.forEach(function(record){
if(filterIds.indexOf(record.documentID)
>
-1) {
if(!pageNumber || (result.recordsCount
>
= start
&&
result.recordsCount
<
finish)) {
result.result.push(record);
}
result.recordsCount++;
}
});
return result;
}
this.getCurrentPage = function(){
return currentPage;
};
this.getRecordsCount = function() {
return recordsCount;
};
this.getPagesCount = function(){
var pagesCount = Math.floor(recordsCount/countInPage);
if(recordsCount%countInPage) {
pagesCount++;
}
return pagesCount;
};
this.getSelectedData = function() {
return table.getSelectedData();
};
this.loadData(0, this.filterID);
this.on = function(event, handler){
table.on(event, handler);
};
this.getSelectedData = function(){
return table.getSelectedData();
};
this.getWidget = function(){
return table.getWidget();
};
};
var RegistryChooser = function(registry, multiChoose, filterIds, selectedIds, handler){
var instance = this;
this.container = jQuery("
<
div
>
");
var searchInput = jQuery("
<
input
>
", {style : "color: #606060; height: 32px;box-sizing: border-box; " +
"border: #e2e2e2 1px solid;border-radius: 4px;padding-left: 9px;" +
"vertical-align:top; width: 480px; margin-right:20px", placeHolder : i18n.tr("Поиск")});
var prevPage = jQuery("
<
div
>
", {style : "height: 32px; width: 34px;border: 1px solid #d6d6d6;" +
"border-top-left-radius: 4px; border-bottom-left-radius: 4px; display: inline-block; " +
"box-sizing: border-box;vertical-align:top;vertical-align: middle;font-size: 20px;" +
"padding-left: 5px; line-height: 30px; color: #afafaf; user-select: none"}).html("◄");
var nextPage = jQuery("
<
div
>
", {style : "height: 32px; width: 34px;border: 1px solid #d6d6d6;" +
"border-top-right-radius: 4px; border-bottom-right-radius: 4px; display: inline-block;" +
"box-sizing: border-box;vertical-align: middle;font-size: 20px;" +
"padding-left: 5px; line-height: 30px; color: #afafaf; user-select: none"}).html("►");
var pageNumber = jQuery("
<
div
>
", {style : "display: inline-block;border: #e2e2e2 1px solid;width: 80px;" +
"height: 32px;box-sizing: border-box;vertical-align:top;text-align: center; line-height: 32px;"});
var selectedButton = jQuery("
<
div
>
", {style : "padding-left : 20px; padding-right:20px; height: 30px;" +
"line-height: 30px;border:#55cc95 1px solid; border-radius: 4px; cursor: pointer;" +
"text-align: center; color: #ffffff; background-color:#55cc95; font-family: DroidSansBold;" +
"font-size: 14px; width:130px; margin:0 auto"});
var selectAll = jQuery('
<
input/
>
', {type: "checkbox", style: 'display: inline-block ; vertical-align: middle;'});
var selectAllLabel = jQuery('
<
label/
>
', {style: "color: #606060; font-family: DroidSans, arial, serif; " +
"font-size: 13px; display: inline-block; margin-right:30px"});
selectAllLabel.append(selectAll);
selectAllLabel.append(jQuery("
<
span
>
").html(i18n.tr("Выбрать все")));
selectedButton.html(i18n.tr("Выбрать"));
var tableScroll = jQuery("
<
div
>
", {style : "width: 780px; height : 460px; border: 1px solid #efefef; overflow : auto; margin-top: 5px; margin-bottom: 5px;"});
var headerPanel = jQuery("
<
div
>
");
headerPanel.append(searchInput);
if(multiChoose) {
headerPanel.append(selectAllLabel);
} else {
searchInput.css("width", "610px");
}
headerPanel.append(prevPage);
headerPanel.append(pageNumber);
headerPanel.append(nextPage);
var selectedData = [];
selectedIds.forEach(function(selectedId){
selectedData.push({documentId : selectedId});
});
var registryTable = new RegistryTable(registry, multiChoose, filterIds, selectedData);
registryTable.addDataClicked(function(){
selectAll.removeAttr("checked");
});
var currentPage = 1;
registryTable.on(MultiTableEvent.dataLoaded, function () {
currentPage = registryTable.getCurrentPage() + 1;
var totalPage = registryTable.getPagesCount();
if (isNaN(totalPage)) {
totalPage = 0;
}
if (totalPage === 0) {
currentPage = 0;
}
pageNumber.html(currentPage+"/"+totalPage);
});
registryTable.dblclick(function () {
if(multiChoose) return;
if (registryTable.getSelectedData().length == 0) return;
instance.close(true);
});
selectedButton.click(function(){
instance.close(true);
});
this.close = function (executeHandler){
if(executeHandler === true) {
handler(registryTable.getSelectedData());
}
instance.container.dialog("destroy");
};
prevPage.click(function(){
if(currentPage
<
= 1) return;
currentPage = currentPage - 1;
registryTable.loadData(currentPage-1);
});
nextPage.click(function(){
if(currentPage
>
= registryTable.getPagesCount()) return;
currentPage = currentPage + 1;
registryTable.loadData(currentPage-1);
});
selectAll.click(function(){
registryTable.selectAll();
});
searchInput.keypress(function (event) {
if (event.keyCode == KEY_CODES.ENTER) {
registryTable.search(searchInput.val());
}
});
this.show = function(){
instance.container.dialog({
width : 800,
height : 600,
title: i18n.tr("Выбор записей реестра: ")+registry.name,
modal: true,
close : function(){
instance.close(false);
}
});
};
tableScroll.append(registryTable.getWidget());
this.container.append(headerPanel);
this.container.append(tableScroll);
this.container.append(selectedButton);
};
</javascript>
<html></html>
</customComponent>
</objects>
<dependencies/>
</configuration>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment