|
|
|
@ -15,19 +15,19 @@ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var getVisibilityValue = function (visibilityField, record) { |
|
|
|
var getVisibilityValue = function (visibilityField, record, tableInstance) { |
|
|
|
if (visibilityField === undefined) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
if (abp.utils.isFunction(visibilityField)) { |
|
|
|
return visibilityField(record); |
|
|
|
return visibilityField(record, tableInstance); |
|
|
|
} else { |
|
|
|
return visibilityField; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var _createDropdownItem = function (record, fieldItem) { |
|
|
|
var _createDropdownItem = function (record, fieldItem, tableInstance) { |
|
|
|
var $li = $('<li/>'); |
|
|
|
var $a = $('<a/>'); |
|
|
|
|
|
|
|
@ -50,14 +50,14 @@ |
|
|
|
|
|
|
|
if (!$(this).closest('li').hasClass('disabled')) { |
|
|
|
if (fieldItem.confirmMessage) { |
|
|
|
abp.message.confirm(fieldItem.confirmMessage({ record: record })) |
|
|
|
abp.message.confirm(fieldItem.confirmMessage({ record: record, table: tableInstance })) |
|
|
|
.done(function (accepted) { |
|
|
|
if (accepted) { |
|
|
|
fieldItem.action({ record: record }); |
|
|
|
fieldItem.action({ record: record, table: tableInstance }); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
fieldItem.action({ record: record }); |
|
|
|
fieldItem.action({ record: record, table: tableInstance }); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
@ -67,17 +67,60 @@ |
|
|
|
return $li; |
|
|
|
}; |
|
|
|
|
|
|
|
var _createButtonDropdown = function (record, field) { |
|
|
|
var _createButtonDropdown = function (record, field, tableInstance) { |
|
|
|
if(field.items.length === 1) { |
|
|
|
var firstItem = field.items[0]; |
|
|
|
if (!getVisibilityValue(firstItem.visible, record, tableInstance)) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
var $button = $('<button type="button" class="btn btn-primary"></button>'); |
|
|
|
|
|
|
|
if (firstItem.displayNameHtml) { |
|
|
|
$button.html(firstItem.text); |
|
|
|
} else { |
|
|
|
if (firstItem.icon !== undefined && firstItem.icon) { |
|
|
|
$button.append($("<i>").addClass("fa fa-" + firstItem.icon + " mr-1")); |
|
|
|
} else if (firstItem.iconClass) { |
|
|
|
$button.append($("<i>").addClass(firstItem.iconClass + " mr-1")); |
|
|
|
} |
|
|
|
$button.append(firstItem.text); |
|
|
|
} |
|
|
|
|
|
|
|
if (firstItem.enabled && !firstItem.enabled({ record: record, table: tableInstance })) { |
|
|
|
$button.addClass('disabled'); |
|
|
|
} |
|
|
|
|
|
|
|
if (firstItem.action) { |
|
|
|
$button.click(function (e) { |
|
|
|
e.preventDefault(); |
|
|
|
|
|
|
|
if (!$(this).hasClass('disabled')) { |
|
|
|
if (firstItem.confirmMessage) { |
|
|
|
abp.message.confirm(firstItem.confirmMessage({ record: record, table: tableInstance })) |
|
|
|
.done(function (accepted) { |
|
|
|
if (accepted) { |
|
|
|
firstItem.action({ record: record, table: tableInstance }); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
firstItem.action({ record: record, table: tableInstance }); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return $button; |
|
|
|
} |
|
|
|
|
|
|
|
var $container = $('<div/>') |
|
|
|
.addClass('dropdown') |
|
|
|
.addClass('action-button'); |
|
|
|
|
|
|
|
var $dropdownButton = $('<button/>'); |
|
|
|
|
|
|
|
if (field.icon !== undefined) { |
|
|
|
if (field.icon) { |
|
|
|
$dropdownButton.append($("<i>").addClass("fa fa-" + field.icon + " mr-1")); |
|
|
|
} |
|
|
|
if (field.icon !== undefined && field.icon) { |
|
|
|
$dropdownButton.append($("<i>").addClass("fa fa-" + field.icon + " mr-1")); |
|
|
|
} else if (field.iconClass) { |
|
|
|
$dropdownButton.append($("<i>").addClass(field.iconClass + " mr-1")); |
|
|
|
} else { |
|
|
|
@ -105,14 +148,14 @@ |
|
|
|
for (var i = 0; i < field.items.length; i++) { |
|
|
|
var fieldItem = field.items[i]; |
|
|
|
|
|
|
|
var isVisible = getVisibilityValue(fieldItem.visible, record); |
|
|
|
var isVisible = getVisibilityValue(fieldItem.visible, record, tableInstance); |
|
|
|
if (!isVisible) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
var $dropdownItem = _createDropdownItem(record, fieldItem); |
|
|
|
var $dropdownItem = _createDropdownItem(record, fieldItem, tableInstance); |
|
|
|
|
|
|
|
if (fieldItem.enabled && !fieldItem.enabled({ record: record })) { |
|
|
|
if (fieldItem.enabled && !fieldItem.enabled({ record: record, table: tableInstance })) { |
|
|
|
$dropdownItem.addClass('disabled'); |
|
|
|
} |
|
|
|
|
|
|
|
@ -131,10 +174,10 @@ |
|
|
|
return $container; |
|
|
|
}; |
|
|
|
|
|
|
|
var _createSingleButton = function (record, field) { |
|
|
|
var _createSingleButton = function (record, field, tableInstance) { |
|
|
|
$(field.element).data(record); |
|
|
|
|
|
|
|
var isVisible = getVisibilityValue(field.visible, record); |
|
|
|
var isVisible = getVisibilityValue(field.visible, record, tableInstance); |
|
|
|
|
|
|
|
if (isVisible) { |
|
|
|
return field.element; |
|
|
|
@ -147,7 +190,7 @@ |
|
|
|
if (field.items && field.items.length > 0) { |
|
|
|
return _createButtonDropdown(record, field, tableInstance); |
|
|
|
} else if (field.element) { |
|
|
|
var $singleActionButton = _createSingleButton(record, field); |
|
|
|
var $singleActionButton = _createSingleButton(record, field, tableInstance); |
|
|
|
if ($singleActionButton === "") { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|