Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/enhancement/datagrid-records-set'
Browse files Browse the repository at this point in the history
  • Loading branch information
danrot committed Jun 3, 2016
2 parents cb3efc5 + 8511698 commit 9124277
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG for husky

* dev-master
* ENHANCEMENT #657 Added new function 'records.set' for datagrid

* 0.19.3 (2016-06-01)
* HOTFIX #649 Use correct culture name when loocale includes country

Expand Down
29 changes: 27 additions & 2 deletions dist/husky.js
Original file line number Diff line number Diff line change
Expand Up @@ -33483,6 +33483,15 @@ define('husky_components/datagrid/decorators/infinite-scroll-pagination',[],func
return this.createEventName('records.change');
},

/**
* Deletes all records, sets given records and updates the view
* @event husky.datagrid.records.set
* @param {Array} array of data-records
*/
RECORDS_SET = function() {
return this.createEventName('records.set');
},

/**
* raised when limit of request changed
* @event husky.datagrid.page-size.changed
Expand Down Expand Up @@ -34488,6 +34497,7 @@ define('husky_components/datagrid/decorators/infinite-scroll-pagination',[],func
this.sandbox.on(RECORDS_ADD.call(this), this.addRecordsHandler.bind(this));
this.sandbox.on(RECORD_REMOVE.call(this), this.removeRecordHandler.bind(this));
this.sandbox.on(RECORDS_CHANGE.call(this), this.changeRecordsHandler.bind(this));
this.sandbox.on(RECORDS_SET.call(this), this.setRecordsHandler.bind(this));
this.sandbox.on(NUMBER_SELECTIONS.call(this), this.updateSelectedCounter.bind(this));
this.sandbox.on(MEDIUM_LOADER_SHOW.call(this), this.showMediumLoader.bind(this));
this.sandbox.on(MEDIUM_LOADER_HIDE.call(this), this.hideMediumLoader.bind(this));
Expand Down Expand Up @@ -34661,7 +34671,7 @@ define('husky_components/datagrid/decorators/infinite-scroll-pagination',[],func

/**
* Merges one or more data-records with a given ones and updates the view
* @param records {Object|Array} the new data-record or an array of data-records
* @param {Object|Array} records the new data-record or an array of data-records
*/
changeRecordsHandler: function(records) {
if (!this.sandbox.dom.isArray(records)) {
Expand All @@ -34675,9 +34685,24 @@ define('husky_components/datagrid/decorators/infinite-scroll-pagination',[],func
this.rerenderPagination();
},

/**
* Deletes all records, sets given records and updates the view
* @param {Array} records array of data-records
*/
setRecordsHandler: function(records) {
// Delete all records.
this.data.embedded = [];

// Add the records.
this.pushRecords(records);

this.rerenderView();
this.rerenderPagination();
},

/**
* calls the clickCallback for an item
* @param id {Number|String} the id of the item
* @param {Number|String} id the id of the item
*/
itemClicked: function(id) {
if (typeof this.options.clickCallback === 'function') {
Expand Down
2 changes: 1 addition & 1 deletion dist/husky.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/husky.min.js

Large diffs are not rendered by default.

29 changes: 27 additions & 2 deletions husky_components/datagrid/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@
return this.createEventName('records.change');
},

/**
* Deletes all records, sets given records and updates the view
* @event husky.datagrid.records.set
* @param {Array} array of data-records
*/
RECORDS_SET = function() {
return this.createEventName('records.set');
},

/**
* raised when limit of request changed
* @event husky.datagrid.page-size.changed
Expand Down Expand Up @@ -1515,6 +1524,7 @@
this.sandbox.on(RECORDS_ADD.call(this), this.addRecordsHandler.bind(this));
this.sandbox.on(RECORD_REMOVE.call(this), this.removeRecordHandler.bind(this));
this.sandbox.on(RECORDS_CHANGE.call(this), this.changeRecordsHandler.bind(this));
this.sandbox.on(RECORDS_SET.call(this), this.setRecordsHandler.bind(this));
this.sandbox.on(NUMBER_SELECTIONS.call(this), this.updateSelectedCounter.bind(this));
this.sandbox.on(MEDIUM_LOADER_SHOW.call(this), this.showMediumLoader.bind(this));
this.sandbox.on(MEDIUM_LOADER_HIDE.call(this), this.hideMediumLoader.bind(this));
Expand Down Expand Up @@ -1688,7 +1698,7 @@

/**
* Merges one or more data-records with a given ones and updates the view
* @param records {Object|Array} the new data-record or an array of data-records
* @param {Object|Array} records the new data-record or an array of data-records
*/
changeRecordsHandler: function(records) {
if (!this.sandbox.dom.isArray(records)) {
Expand All @@ -1702,9 +1712,24 @@
this.rerenderPagination();
},

/**
* Deletes all records, sets given records and updates the view
* @param {Array} records array of data-records
*/
setRecordsHandler: function(records) {
// Delete all records.
this.data.embedded = [];

// Add the records.
this.pushRecords(records);

this.rerenderView();
this.rerenderPagination();
},

/**
* calls the clickCallback for an item
* @param id {Number|String} the id of the item
* @param {Number|String} id the id of the item
*/
itemClicked: function(id) {
if (typeof this.options.clickCallback === 'function') {
Expand Down

0 comments on commit 9124277

Please sign in to comment.