@girder/core 3.1.2 → 3.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@girder/core",
3
- "version": "3.1.2",
3
+ "version": "3.1.13",
4
4
  "description": "Extensible data management platform",
5
5
  "homepage": "https://girder.readthedocs.org",
6
6
  "bugs": {
@@ -684,6 +684,7 @@ var HierarchyWidget = View.extend({
684
684
  yesText: 'Delete',
685
685
  confirmCallback: () => {
686
686
  var resources = this._getCheckedResourceParam();
687
+ var resourceSize = this._getCheckedResourceSize();
687
688
  /* Content on DELETE requests is somewhat oddly supported (I
688
689
  * can't get it to work under jasmine/phantom), so override the
689
690
  * method. */
@@ -699,7 +700,9 @@ var HierarchyWidget = View.extend({
699
700
  if (folders.length && this.parentModel.has('nFolders')) {
700
701
  this.parentModel.increment('nFolders', -folders.length);
701
702
  }
702
-
703
+ if (this.parentModel.has('size') && resourceSize.items) {
704
+ this.parentModel.increment('size', -resourceSize.items);
705
+ }
703
706
  this.setCurrentModel(this.parentModel, { setRoute: false });
704
707
  });
705
708
  }
@@ -855,6 +858,26 @@ var HierarchyWidget = View.extend({
855
858
  return JSON.stringify(resources);
856
859
  },
857
860
 
861
+ /**
862
+ * Get the sum of the sizes of checked resources.
863
+ */
864
+ _getCheckedResourceSize: function () {
865
+ var totalSize = { items: 0, folders: 0 };
866
+ var folders = this.folderListView.checked;
867
+ _.each(folders, function (cid) {
868
+ var folder = this.folderListView.collection.get(cid);
869
+ totalSize.folders += (folder.get('size') || 0);
870
+ }, this);
871
+ if (this.itemListView) {
872
+ var items = this.itemListView.checked;
873
+ _.each(items, function (cid) {
874
+ var item = this.itemListView.collection.get(cid);
875
+ totalSize.items += (item.get('size') || 0);
876
+ }, this);
877
+ }
878
+ return totalSize;
879
+ },
880
+
858
881
  downloadChecked: function () {
859
882
  var url = getApiRoot() + '/resource/download';
860
883
  var resources = this._getCheckedResourceParam();
@@ -85,7 +85,7 @@ var ItemListWidget = View.extend({
85
85
  restRequest({
86
86
  url: `item/${this._selectedItem.get('_id')}/position`,
87
87
  method: 'GET',
88
- data: { folderId: this._selectedItem.get('folderId') }
88
+ data: { folderId: this._selectedItem.get('folderId'), sort: 'name' }
89
89
  }).done((val) => {
90
90
  // Now we fetch the correct page for the position
91
91
  val = Number(val);
@@ -237,11 +237,16 @@ var ItemListWidget = View.extend({
237
237
  centerSelected: function () {
238
238
  const widgetcontainer = this.$el.parents('.g-hierarchy-widget-container');
239
239
  const selected = this.$('li.g-item-list-entry.g-selected');
240
-
241
240
  if (widgetcontainer.length > 0 && selected.length > 0) {
242
- const centerPos = (widgetcontainer.height() / 2.0) + (selected.outerHeight() / 2.0);
243
- // Take the current scroll top position and add it to the position of the top of the selected item, then center it
244
- const scrollPos = widgetcontainer[0].scrollTop + selected.position().top - centerPos;
241
+ // These items will effect the scroll position if they exists
242
+ const folderHeight = $('.g-folder-list').length ? $('.g-folder-list').height() : 0;
243
+ const breadcrumbHeight = $('.g-hierarchy-breadcrumb-bar').length ? $('.g-hierarchy-breadcrumb-bar').height() : 0;
244
+ const selectedTop = selected.position().top;
245
+ // The selectedTop position needs to account for the breadcrumbHeight and the folderHeight
246
+ const scrollingPos = selectedTop + folderHeight + breadcrumbHeight;
247
+ const centerPos = (widgetcontainer.height() / 2.0) - (folderHeight / 2.0) - (breadcrumbHeight / 2.0) - (selected.outerHeight() / 2.0);
248
+
249
+ const scrollPos = scrollingPos - centerPos;
245
250
  if (this.tempScrollPos === undefined) {
246
251
  this.tempScrollPos = scrollPos;
247
252
  }