mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Misc fixes and additions for pgAgent support:
- Added DatetimepickerControl, MomentCell (using moment.js) - Used the 'DatetimepickerControl' in Role (Also - resolved an issue, when unset the datetime for 'Valid Until'.) - Added a 'Select All/Unselect All' adaptor for Select2 used by pgAgent nodes. - Fixed an issue with SubNodeCollectionControl, which was not starting the modification session of the child model, when created default value for collection is not null/undefined. And, hence - validation on the child model was not working. - Fixed a memory leak with SqlFieldControl, and SqlTabControl, which was not releasing the CodeMirror properly.
This commit is contained in:
@@ -1,9 +1,81 @@
|
||||
define(
|
||||
['jquery', 'underscore', 'pgadmin', 'backbone', 'backform', 'alertify', 'pgadmin.browser.node'],
|
||||
define([
|
||||
'jquery', 'underscore', 'pgadmin', 'backbone', 'backform', 'alertify',
|
||||
'pgadmin.browser.node', 'pgadmin.browser.messages'
|
||||
],
|
||||
function($, _, pgAdmin, Backbone, Backform, Alertify, Node) {
|
||||
|
||||
var pgBrowser = pgAdmin.Browser;
|
||||
|
||||
/*
|
||||
* Define the selectAll adapter for select2.
|
||||
*
|
||||
* Reference:
|
||||
* https://github.com/select2/select2/issues/195#issuecomment-240130634
|
||||
*/
|
||||
$.fn.select2.amd.define('select2/selectAllAdapter', [
|
||||
'select2/utils',
|
||||
'select2/dropdown',
|
||||
'select2/dropdown/attachBody'
|
||||
], function (Utils, Dropdown, AttachBody) {
|
||||
|
||||
function SelectAll() { }
|
||||
SelectAll.prototype.render = function (decorated) {
|
||||
var self = this,
|
||||
$rendered = decorated.call(this),
|
||||
$selectAll = $([
|
||||
'<button class="btn btn-xs btn-default" type="button"',
|
||||
' style="width: 49%;margin: 0 0.5%;">',
|
||||
'<i class="fa fa-check-square-o"></i>',
|
||||
'<span style="padding: 0px 5px;">',
|
||||
pgAdmin.Browser.messages['SELECT_ALL'],
|
||||
'</span></button>'
|
||||
].join('')),
|
||||
$unselectAll = $([
|
||||
'<button class="btn btn-xs btn-default" type="button"',
|
||||
' style="width: 49%;margin: 0 0.5%;">',
|
||||
'<i class="fa fa-square-o"></i><span style="padding: 0px 5px;">',
|
||||
pgAdmin.Browser.messages['UNSELECT_ALL'],
|
||||
'</span></button>'
|
||||
].join('')),
|
||||
$btnContainer = $(
|
||||
'<div style="padding: 3px 0px; background-color: #2C76B4; margin-bottom: 3px;">'
|
||||
).append($selectAll).append($unselectAll);
|
||||
|
||||
if (!this.$element.prop("multiple")) {
|
||||
// this isn't a multi-select -> don't add the buttons!
|
||||
return $rendered;
|
||||
}
|
||||
$rendered.find('.select2-dropdown').prepend($btnContainer);
|
||||
$selectAll.on('click', function (e) {
|
||||
var $results = $rendered.find('.select2-results__option[aria-selected=false]');
|
||||
$results.each(function () {
|
||||
self.trigger('select', {
|
||||
data: $(this).data('data')
|
||||
});
|
||||
});
|
||||
self.trigger('close');
|
||||
});
|
||||
$unselectAll.on('click', function (e) {
|
||||
var $results = $rendered.find('.select2-results__option[aria-selected=true]');
|
||||
$results.each(function () {
|
||||
self.trigger('unselect', {
|
||||
data: $(this).data('data')
|
||||
});
|
||||
});
|
||||
self.trigger('close');
|
||||
});
|
||||
return $rendered;
|
||||
};
|
||||
|
||||
return Utils.Decorate(
|
||||
Utils.Decorate(
|
||||
Dropdown,
|
||||
AttachBody
|
||||
),
|
||||
SelectAll
|
||||
);
|
||||
});
|
||||
|
||||
/*
|
||||
* NodeAjaxOptionsControl
|
||||
* This control will fetch the options required to render the select
|
||||
|
||||
Reference in New Issue
Block a user