@girder/core 3.2.8 → 5.0.0-a7

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.
Files changed (231) hide show
  1. package/README.md +61 -0
  2. package/package.json +79 -31
  3. package/assets/Girder_Mark.png +0 -0
  4. package/auth.js +0 -152
  5. package/collections/ApiKeyCollection.js +0 -9
  6. package/collections/AssetstoreCollection.js +0 -9
  7. package/collections/Collection.js +0 -295
  8. package/collections/CollectionCollection.js +0 -9
  9. package/collections/FileCollection.js +0 -11
  10. package/collections/FolderCollection.js +0 -11
  11. package/collections/GroupCollection.js +0 -9
  12. package/collections/ItemCollection.js +0 -11
  13. package/collections/UserCollection.js +0 -24
  14. package/collections/index.js +0 -21
  15. package/constants.js +0 -33
  16. package/dialog.js +0 -128
  17. package/events.js +0 -6
  18. package/index.js +0 -31
  19. package/main.js +0 -21
  20. package/misc.js +0 -260
  21. package/models/AccessControlledModel.js +0 -76
  22. package/models/ApiKeyModel.js +0 -31
  23. package/models/AssetstoreModel.js +0 -43
  24. package/models/CollectionCreationPolicyModel.js +0 -20
  25. package/models/CollectionModel.js +0 -12
  26. package/models/FileModel.js +0 -310
  27. package/models/FolderModel.js +0 -33
  28. package/models/GroupModel.js +0 -197
  29. package/models/ItemModel.js +0 -72
  30. package/models/MetadataMixin.js +0 -88
  31. package/models/Model.js +0 -187
  32. package/models/UserModel.js +0 -189
  33. package/models/index.js +0 -25
  34. package/pluginUtils.js +0 -11
  35. package/rest.js +0 -216
  36. package/router.js +0 -58
  37. package/routes.js +0 -231
  38. package/stylesheets/apidocs/apidocs.styl +0 -50
  39. package/stylesheets/body/adminConsole.styl +0 -21
  40. package/stylesheets/body/assetstores.styl +0 -46
  41. package/stylesheets/body/collectionList.styl +0 -39
  42. package/stylesheets/body/collectionPage.styl +0 -6
  43. package/stylesheets/body/frontPage.styl +0 -48
  44. package/stylesheets/body/groupList.styl +0 -43
  45. package/stylesheets/body/groupPage.styl +0 -116
  46. package/stylesheets/body/itemPage.styl +0 -81
  47. package/stylesheets/body/plugins.styl +0 -61
  48. package/stylesheets/body/searchResultsList.styl +0 -51
  49. package/stylesheets/body/systemConfig.styl +0 -56
  50. package/stylesheets/body/userAccount.styl +0 -57
  51. package/stylesheets/body/userList.styl +0 -79
  52. package/stylesheets/body/userPage.styl +0 -6
  53. package/stylesheets/layout/footer.styl +0 -19
  54. package/stylesheets/layout/global.styl +0 -154
  55. package/stylesheets/layout/globalNav.styl +0 -89
  56. package/stylesheets/layout/header.styl +0 -29
  57. package/stylesheets/layout/headerUser.styl +0 -33
  58. package/stylesheets/layout/layout.styl +0 -75
  59. package/stylesheets/layout/layoutVars.styl +0 -9
  60. package/stylesheets/layout/loading.styl +0 -37
  61. package/stylesheets/layout/progressArea.styl +0 -17
  62. package/stylesheets/widgets/accessWidget.styl +0 -106
  63. package/stylesheets/widgets/browserWidget.styl +0 -9
  64. package/stylesheets/widgets/hierarchyWidget.styl +0 -188
  65. package/stylesheets/widgets/markdownWidget.styl +0 -92
  66. package/stylesheets/widgets/metadataWidget.styl +0 -92
  67. package/stylesheets/widgets/searchFieldWidget.styl +0 -70
  68. package/stylesheets/widgets/taskProgress.styl +0 -41
  69. package/stylesheets/widgets/timelineWidget.styl +0 -41
  70. package/stylesheets/widgets/uploadWidget.styl +0 -43
  71. package/stylesheets/widgets/userOtpManagementWidget.styl +0 -159
  72. package/templates/body/adminConsole.pug +0 -13
  73. package/templates/body/assetstores.pug +0 -98
  74. package/templates/body/collectionList.pug +0 -40
  75. package/templates/body/collectionPage.pug +0 -36
  76. package/templates/body/filesystemImport.pug +0 -41
  77. package/templates/body/frontPage.pug +0 -83
  78. package/templates/body/groupList.pug +0 -30
  79. package/templates/body/groupPage.pug +0 -116
  80. package/templates/body/itemPage.pug +0 -61
  81. package/templates/body/plugins.pug +0 -20
  82. package/templates/body/s3Import.pug +0 -35
  83. package/templates/body/searchResults.pug +0 -15
  84. package/templates/body/searchResultsType.pug +0 -13
  85. package/templates/body/systemConfiguration.pug +0 -221
  86. package/templates/body/userAccount.pug +0 -83
  87. package/templates/body/userList.pug +0 -43
  88. package/templates/body/userPage.pug +0 -40
  89. package/templates/layout/alert.pug +0 -5
  90. package/templates/layout/layout.pug +0 -12
  91. package/templates/layout/layoutFooter.pug +0 -11
  92. package/templates/layout/layoutGlobalNav.pug +0 -7
  93. package/templates/layout/layoutHeader.pug +0 -8
  94. package/templates/layout/layoutHeaderUser.pug +0 -26
  95. package/templates/layout/layoutProgressArea.pug +0 -1
  96. package/templates/layout/loginDialog.pug +0 -30
  97. package/templates/layout/registerDialog.pug +0 -35
  98. package/templates/layout/resetPasswordDialog.pug +0 -25
  99. package/templates/widgets/accessEditor.pug +0 -23
  100. package/templates/widgets/accessEditorMixins.pug +0 -57
  101. package/templates/widgets/accessEditorNonModal.pug +0 -11
  102. package/templates/widgets/accessEntry.pug +0 -32
  103. package/templates/widgets/apiKeyList.pug +0 -50
  104. package/templates/widgets/browserWidget.pug +0 -32
  105. package/templates/widgets/checkedActionsMenu.pug +0 -46
  106. package/templates/widgets/collectionInfoDialog.pug +0 -37
  107. package/templates/widgets/confirmDialog.pug +0 -14
  108. package/templates/widgets/dateTimeRangeWidget.pug +0 -20
  109. package/templates/widgets/dateTimeWidget.pug +0 -8
  110. package/templates/widgets/editApiKeyWidget.pug +0 -43
  111. package/templates/widgets/editAssetstoreWidget.pug +0 -78
  112. package/templates/widgets/editCollectionWidget.pug +0 -27
  113. package/templates/widgets/editFileWidget.pug +0 -21
  114. package/templates/widgets/editFolderWidget.pug +0 -27
  115. package/templates/widgets/editGroupWidget.pug +0 -54
  116. package/templates/widgets/editItemWidget.pug +0 -27
  117. package/templates/widgets/fileInfoDialog.pug +0 -33
  118. package/templates/widgets/fileList.pug +0 -33
  119. package/templates/widgets/folderInfoDialog.pug +0 -42
  120. package/templates/widgets/folderList.pug +0 -21
  121. package/templates/widgets/groupAdminList.pug +0 -33
  122. package/templates/widgets/groupInviteDialog.pug +0 -76
  123. package/templates/widgets/groupInviteList.pug +0 -14
  124. package/templates/widgets/groupMemberList.pug +0 -39
  125. package/templates/widgets/groupModList.pug +0 -23
  126. package/templates/widgets/hierarchyBreadcrumb.pug +0 -37
  127. package/templates/widgets/hierarchyPaginated.pug +0 -19
  128. package/templates/widgets/hierarchyWidget.pug +0 -96
  129. package/templates/widgets/itemBreadcrumb.pug +0 -16
  130. package/templates/widgets/itemList.pug +0 -27
  131. package/templates/widgets/jsonMetadatumEditWidget.pug +0 -13
  132. package/templates/widgets/jsonMetadatumView.pug +0 -6
  133. package/templates/widgets/loadingAnimation.pug +0 -4
  134. package/templates/widgets/markdownWidget.pug +0 -34
  135. package/templates/widgets/metadataWidget.pug +0 -16
  136. package/templates/widgets/metadatumEditWidget.pug +0 -15
  137. package/templates/widgets/metadatumView.pug +0 -5
  138. package/templates/widgets/newAssetstore.pug +0 -118
  139. package/templates/widgets/paginateWidget.pug +0 -7
  140. package/templates/widgets/pluginConfigBreadcrumb.pug +0 -13
  141. package/templates/widgets/rootSelectorWidget.pug +0 -13
  142. package/templates/widgets/searchField.pug +0 -10
  143. package/templates/widgets/searchHelp.pug +0 -12
  144. package/templates/widgets/searchModeSelect.pug +0 -9
  145. package/templates/widgets/searchResults.pug +0 -14
  146. package/templates/widgets/sortCollectionWidget.pug +0 -14
  147. package/templates/widgets/taskProgress.pug +0 -16
  148. package/templates/widgets/timeline.pug +0 -15
  149. package/templates/widgets/uploadWidget.pug +0 -15
  150. package/templates/widgets/uploadWidgetMixins.pug +0 -31
  151. package/templates/widgets/uploadWidgetNonModal.pug +0 -10
  152. package/templates/widgets/userOtpBegin.pug +0 -4
  153. package/templates/widgets/userOtpDisable.pug +0 -6
  154. package/templates/widgets/userOtpEnable.pug +0 -44
  155. package/utilities/EventStream.js +0 -177
  156. package/utilities/PluginUtils.js +0 -36
  157. package/utilities/S3UploadHandler.js +0 -303
  158. package/utilities/index.js +0 -9
  159. package/utilities/jquery/girderEnable.js +0 -19
  160. package/utilities/jquery/girderModal.js +0 -48
  161. package/version.js +0 -10
  162. package/views/App.js +0 -359
  163. package/views/View.js +0 -78
  164. package/views/body/AdminView.js +0 -29
  165. package/views/body/AssetstoresView.js +0 -235
  166. package/views/body/CollectionView.js +0 -188
  167. package/views/body/CollectionsView.js +0 -120
  168. package/views/body/FilesystemImportView.js +0 -83
  169. package/views/body/FolderView.js +0 -54
  170. package/views/body/FrontPageView.js +0 -47
  171. package/views/body/GroupView.js +0 -336
  172. package/views/body/GroupsView.js +0 -106
  173. package/views/body/ItemView.js +0 -177
  174. package/views/body/PluginsView.js +0 -73
  175. package/views/body/S3ImportView.js +0 -80
  176. package/views/body/SearchResultsView.js +0 -162
  177. package/views/body/SystemConfigurationView.js +0 -196
  178. package/views/body/UserAccountView.js +0 -179
  179. package/views/body/UserView.js +0 -165
  180. package/views/body/UsersView.js +0 -124
  181. package/views/body/index.js +0 -37
  182. package/views/index.js +0 -13
  183. package/views/layout/FooterView.js +0 -29
  184. package/views/layout/GlobalNavView.js +0 -103
  185. package/views/layout/HeaderUserView.js +0 -45
  186. package/views/layout/HeaderView.js +0 -83
  187. package/views/layout/LoginView.js +0 -100
  188. package/views/layout/ProgressListView.js +0 -70
  189. package/views/layout/RegisterView.js +0 -101
  190. package/views/layout/ResetPasswordView.js +0 -70
  191. package/views/layout/index.js +0 -19
  192. package/views/widgets/AccessWidget.js +0 -427
  193. package/views/widgets/ApiKeyListWidget.js +0 -140
  194. package/views/widgets/BrowserWidget.js +0 -317
  195. package/views/widgets/CheckedMenuWidget.js +0 -68
  196. package/views/widgets/CollectionInfoWidget.js +0 -40
  197. package/views/widgets/DateTimeRangeWidget.js +0 -179
  198. package/views/widgets/DateTimeWidget.js +0 -109
  199. package/views/widgets/EditApiKeyWidget.js +0 -122
  200. package/views/widgets/EditAssetstoreWidget.js +0 -148
  201. package/views/widgets/EditCollectionWidget.js +0 -93
  202. package/views/widgets/EditFileWidget.js +0 -56
  203. package/views/widgets/EditFolderWidget.js +0 -116
  204. package/views/widgets/EditGroupWidget.js +0 -125
  205. package/views/widgets/EditItemWidget.js +0 -110
  206. package/views/widgets/FileInfoWidget.js +0 -26
  207. package/views/widgets/FileListWidget.js +0 -151
  208. package/views/widgets/FolderInfoWidget.js +0 -39
  209. package/views/widgets/FolderListWidget.js +0 -106
  210. package/views/widgets/GroupAdminsWidget.js +0 -88
  211. package/views/widgets/GroupInvitesWidget.js +0 -56
  212. package/views/widgets/GroupMembersWidget.js +0 -185
  213. package/views/widgets/GroupModsWidget.js +0 -77
  214. package/views/widgets/HierarchyWidget.js +0 -1097
  215. package/views/widgets/ItemBreadcrumbWidget.js +0 -38
  216. package/views/widgets/ItemListWidget.js +0 -345
  217. package/views/widgets/LoadingAnimation.js +0 -17
  218. package/views/widgets/MarkdownWidget.js +0 -217
  219. package/views/widgets/MetadataWidget.js +0 -504
  220. package/views/widgets/NewAssetstoreWidget.js +0 -81
  221. package/views/widgets/PaginateWidget.js +0 -37
  222. package/views/widgets/PluginConfigBreadcrumbWidget.js +0 -33
  223. package/views/widgets/RootSelectorWidget.js +0 -192
  224. package/views/widgets/SearchFieldWidget.js +0 -365
  225. package/views/widgets/SearchPaginateWidget.js +0 -149
  226. package/views/widgets/SortCollectionWidget.js +0 -53
  227. package/views/widgets/TaskProgressWidget.js +0 -91
  228. package/views/widgets/TimelineWidget.js +0 -155
  229. package/views/widgets/UploadWidget.js +0 -340
  230. package/views/widgets/UserOtpManagementWidget.js +0 -105
  231. package/views/widgets/index.js +0 -75
@@ -1,317 +0,0 @@
1
- import $ from 'jquery';
2
- import _ from 'underscore';
3
-
4
- import HierarchyWidget from '@girder/core/views/widgets/HierarchyWidget';
5
- import RootSelectorWidget from '@girder/core/views/widgets/RootSelectorWidget';
6
- import View from '@girder/core/views/View';
7
- import CollectionModel from '@girder/core/models/CollectionModel';
8
- import FolderModel from '@girder/core/models/FolderModel';
9
- import UserModel from '@girder/core/models/UserModel';
10
-
11
- import BrowserWidgetTemplate from '@girder/core/templates/widgets/browserWidget.pug';
12
-
13
- import '@girder/core/stylesheets/widgets/browserWidget.styl';
14
- import '@girder/core/utilities/jquery/girderModal';
15
-
16
- /**
17
- * This widget provides the user with an interface similar to a filesystem
18
- * browser to pick a single user, collection, folder, or item from a
19
- * hierarchical view.
20
- */
21
- var BrowserWidget = View.extend({
22
- events: {
23
- 'click .g-submit-button': function () {
24
- this._validate();
25
- }
26
- },
27
-
28
- /**
29
- * Initialize the widget.
30
- * @param {object} settings
31
- * @param {string} [titleText="Select an item"] Text to display in the modal header
32
- * @param {string} [helpText] Info text to display below the hierarchy widget
33
- * @param {string} [submitText="Save"] Text to display on the submit button
34
- * @param {boolean} [showItems=false] Show items in the hierarchy widget
35
- * @param {boolean} [showPreview=true] Show a preview of the current object id
36
- * @param {function} [validate] A validation function, which is passed the selected model as a
37
- parameter, and which should return a promise. The returned promise should resolve if the
38
- selection is acceptable and reject with a string value (as an error message) if the
39
- selection is unacceptable.
40
- * @param {object} [rootSelectorSettings] Settings passed to the root selector widget
41
- * @param {boolean} [showMetadata=false] Show the metadata editor inside the hierarchy widget
42
- * @param {Model} [root] The default root model to pass to the hierarchy widget
43
- * @param {Model} [defaultSelectedResource] default resource item to be selected. It will start
44
- * the browser with this item selected. Will override the root to the parent of
45
- * the defaultSelectedResource
46
- * @param {boolean} [selectItem=false] Adjust behavior to enable selecting items rather
47
- * than folders. This will add a handler to the hierarchy widget responding to
48
- * clicks on items to select a target rather than inferring it from the browsed
49
- * location.
50
- * @param {object} [input=false] Settings passed to an optional text input box
51
- * The input box is primarily meant to be for a user to enter a file name
52
- * as in a "Save As" dialog. The default (false) hides this element.
53
- * @param {string} [input.label="Name"] A label for the input element.
54
- * @param {string} [input.default] The default value
55
- * @param {function} [input.validate] A validation function, which is passed the value of the
56
- user-specified input element as a parameter, and which should return a promise. The returned
57
- promise should resolve if the selection is acceptable and reject with a string value (as an
58
- error message) if the selection is unacceptable.
59
- * @param {string} [input.placeholder] A placeholder string for the input element.
60
- * @param {boolean} [highlightItem=false] highlights the selected item in the hierarchy and scrolls to it.
61
- * @param {boolean} [paginated=false] the browser widget is paginated
62
- */
63
- initialize: function (settings) {
64
- // store options
65
- settings = settings || {};
66
- this.titleText = settings.titleText || 'Select an item';
67
- this.validate = settings.validate || _.constant($.Deferred().resolve().promise());
68
- this.helpText = settings.helpText;
69
- this.showItems = settings.showItems;
70
- this.showPreview = _.isUndefined(settings.showPreview) ? true : !!settings.showPreview;
71
- this.submitText = settings.submitText || 'Save';
72
- this.root = settings.root;
73
- this.defaultSelectedResource = settings.defaultSelectedResource;
74
- this.input = settings.input;
75
- this.selectItem = !!settings.selectItem;
76
- this.showMetadata = !!settings.showMetadata;
77
- this.highlightItem = !!settings.highlightItem;
78
- this.paginated = !!settings.paginated;
79
- this._selected = null;
80
-
81
- // Sets RootSelectorWidget to open properly to the root if not already set in the settings
82
- if (this.defaultSelectedResource) {
83
- if (!settings.rootSelectorSettings) {
84
- settings.rootSelectorSettings = {};
85
- }
86
- if (!settings.rootSelectorSettings.selectByResource) {
87
- settings.rootSelectorSettings.selectByResource = this.defaultSelectedResource;
88
- }
89
- }
90
- // generate the root selection view and listen to it's events
91
- this._rootSelectionView = new RootSelectorWidget(_.extend({
92
- parentView: this
93
- }, settings.rootSelectorSettings));
94
- this.listenTo(this._rootSelectionView, 'g:selected', function (evt) {
95
- this.root = evt.root;
96
- this._renderHierarchyView();
97
- });
98
- if (this.defaultSelectedResource && !this.root) {
99
- this._calculateDefaultSelectedRoot();
100
- }
101
- },
102
-
103
- render: function () {
104
- const defaultResourcename = (this.defaultSelectedResource && this.defaultSelectedResource.get('name'));
105
- this.$el.html(
106
- BrowserWidgetTemplate({
107
- title: this.titleText,
108
- help: this.helpText,
109
- preview: this.showPreview,
110
- submit: this.submitText,
111
- input: this.input,
112
- selectItem: this.selectItem,
113
- defaultSelectedResource: defaultResourcename
114
- })
115
- ).girderModal(this);
116
- this._renderRootSelection();
117
- return this;
118
- },
119
-
120
- /**
121
- * Return the selected model.
122
- */
123
- selectedModel: function () {
124
- return this._selected;
125
- },
126
-
127
- _renderRootSelection: function () {
128
- this._rootSelectionView.setElement(this.$('.g-hierarchy-root-container')).render();
129
- this._renderHierarchyView();
130
- },
131
-
132
- _renderHierarchyView: function () {
133
- if (this._hierarchyView) {
134
- this.stopListening(this._hierarchyView);
135
- this._hierarchyView.off();
136
- this.$('.g-hierarchy-widget-container').empty();
137
- }
138
- if (!this.root) {
139
- return;
140
- }
141
- this.$('.g-wait-for-root').removeClass('hidden');
142
- this._hierarchyView = new HierarchyWidget({
143
- el: this.$('.g-hierarchy-widget-container'),
144
- parentView: this,
145
- parentModel: this.root,
146
- checkboxes: false,
147
- routing: false,
148
- showActions: false,
149
- showItems: this.showItems,
150
- onItemClick: _.bind(this._selectItem, this),
151
- defaultSelectedResource: this.defaultSelectedResource,
152
- highlightItem: this.highlightItem,
153
- paginated: this.paginated,
154
- showMetadata: this.showMetadata
155
- });
156
- this.listenTo(this._hierarchyView, 'g:setCurrentModel', this._selectModel);
157
- this._selectModel();
158
- },
159
-
160
- _resetSelection: function (model) {
161
- this._selected = model;
162
- this.$('.g-validation-failed-message').addClass('hidden');
163
- this.$('.g-selected-model').removeClass('has-error');
164
- this.$('.g-input-element').removeClass('has-error');
165
- this.$('#g-selected-model').val('');
166
- if (this._selected) {
167
- this.$('#g-selected-model').val(this._selected.get('name'));
168
- if (this.highlightItem && this.selectItem) {
169
- this._hierarchyView.selectItem(this._selected);
170
- } else {
171
- this._hierarchyView.selectFolder(this._selected);
172
- }
173
- }
174
- },
175
-
176
- _selectItem: function (item) {
177
- if (!this.selectItem) {
178
- return;
179
- }
180
- this._resetSelection(item);
181
- },
182
-
183
- _selectModel: function () {
184
- if (this.selectItem) {
185
- return;
186
- }
187
- this._resetSelection(this._hierarchyView.parentModel);
188
- },
189
-
190
- /**
191
- * Independently validate the input-element and the selected-model.
192
- */
193
- _validate: function () {
194
- // Validate input element
195
- let inputValidation;
196
- if (this.input && this.input.validate) {
197
- inputValidation = this.input.validate(this.$('#g-input-element').val());
198
- if (inputValidation === undefined) {
199
- console.warn('Static validation is deprecated, return a promise instead');
200
- inputValidation = $.Deferred().resolve().promise();
201
- } else if (!_.isFunction(inputValidation.then)) {
202
- console.warn('Static validation is deprecated, return a promise instead');
203
- inputValidation = $.Deferred().reject(inputValidation).promise();
204
- }
205
- } else {
206
- // No validator is implicit acceptance
207
- inputValidation = $.Deferred().resolve().promise();
208
- }
209
-
210
- // Validate selected element
211
- const selectedModel = this.selectedModel();
212
- let selectedValidation = this.validate(selectedModel);
213
- if (selectedValidation === undefined) {
214
- console.warn('Static validation is deprecated, return a promise instead');
215
- selectedValidation = $.Deferred().resolve().promise();
216
- } else if (!_.isFunction(selectedValidation.then)) {
217
- console.warn('Static validation is deprecated, return a promise instead');
218
- selectedValidation = $.Deferred().reject(selectedValidation).promise();
219
- }
220
-
221
- let invalidInputElement = null;
222
- let invalidSelectedModel = null;
223
- // We want to wait until both promises to run to completion, which only happens if they're
224
- // accepted. So, chain an extra handler on to them, which transforms a rejection into an
225
- // acceptance.
226
- $.when(
227
- inputValidation
228
- .catch((failMessage) => {
229
- // input-element is invalid
230
- invalidInputElement = failMessage;
231
- return undefined;
232
- }),
233
- selectedValidation
234
- .catch((failMessage) => {
235
- // selected-model is invalid
236
- invalidSelectedModel = failMessage;
237
- return undefined;
238
- })
239
- )
240
- .done(() => {
241
- // Reset any previous error states
242
- this.$('.g-selected-model').removeClass('has-error');
243
- this.$('.g-input-element').removeClass('has-error');
244
- this.$('.g-validation-failed-message').addClass('hidden').html('');
245
-
246
- // The 4 possible outcomes of this validation are as follows...
247
- //
248
- // Case | input-element | selected-model
249
- // 1. | Valid | Valid
250
- // 2. | Valid | Invalid
251
- // 3. | Invalid | Valid
252
- // 4. | Invalid | Invalid
253
- if (!invalidInputElement && !invalidSelectedModel) {
254
- // Case 1
255
- this.root = this._hierarchyView.parentModel;
256
- this.$el.modal('hide');
257
- this.trigger('g:saved', selectedModel, this.$('#g-input-element').val());
258
- } else if (!invalidInputElement && invalidSelectedModel) {
259
- // Case 2
260
- this.$('.g-selected-model').addClass('has-error');
261
- this.$('.g-validation-failed-message').removeClass('hidden').text(invalidSelectedModel);
262
- } else if (invalidInputElement && !invalidSelectedModel) {
263
- // Case 3
264
- this.$('.g-input-element').addClass('has-error');
265
- this.$('.g-validation-failed-message').removeClass('hidden').text(invalidInputElement);
266
- } else if (invalidInputElement && invalidSelectedModel) {
267
- // Case 4
268
- this.$('.g-selected-model').addClass('has-error');
269
- this.$('.g-input-element').addClass('has-error');
270
- this.$('.g-validation-failed-message').removeClass('hidden').html(
271
- _.escape(invalidInputElement) + '<br>' + _.escape(invalidSelectedModel));
272
- }
273
- });
274
- },
275
-
276
- /**
277
- * If we have a defaultSelectedResource we need the root item for the hiearachyWidget
278
- * This will calculate what the root item should be if one hasn't been supplied
279
- */
280
- _calculateDefaultSelectedRoot: function () {
281
- // If we are are only using folders, the root is the defaultselectedResource then
282
- if (!this.selectItem) {
283
- this.root = this.defaultSelectedResource;
284
- return;
285
- }
286
- // We need to calculate the parent model of the default.selectedResoure when selectItem is true
287
- const modelTypes = {
288
- folder: FolderModel,
289
- collection: CollectionModel,
290
- user: UserModel
291
- };
292
- let modelType = 'folder'; // folder type by default, other types if necessary
293
- let modelId = null;
294
- // If it is an item it will have a folderId associated with it as a parent item
295
- if (this.defaultSelectedResource.get('folderId')) {
296
- modelId = this.defaultSelectedResource.get('folderId');
297
- } else if (this.defaultSelectedResource.get('parentCollection')) {
298
- // Case for providing a folder as the defaultSelectedResource but want the user to select an item
299
- // folder parent is either 'user' | 'folder' | 'collection', most likely folder though
300
- modelType = this.defaultSelectedResource.get('parentCollection');
301
- modelId = this.defaultSelectedResource.get('parentId');
302
- }
303
- if (modelTypes[modelType] && modelId) {
304
- const parentModel = new modelTypes[modelType]();
305
- parentModel.set({
306
- _id: modelId
307
- }).on('g:fetched', function () {
308
- this.root = parentModel;
309
- this.render();
310
- }, this).on('g:error', function () {
311
- this.render();
312
- }, this).fetch();
313
- }
314
- }
315
- });
316
-
317
- export default BrowserWidget;
@@ -1,68 +0,0 @@
1
- import HierarchyWidget from '@girder/core/views/widgets/HierarchyWidget';
2
- import View from '@girder/core/views/View';
3
- import { AccessType } from '@girder/core/constants';
4
-
5
- import CheckedActionsMenuTemplate from '@girder/core/templates/widgets/checkedActionsMenu.pug';
6
-
7
- import '@girder/core/utilities/jquery/girderEnable';
8
-
9
- /**
10
- * This widget presents a list of available batch actions
11
- * on a set of selected resources.
12
- */
13
- var CheckedMenuWidget = View.extend({
14
-
15
- initialize: function (params) {
16
- this._fetchAndInit(params);
17
- this.dropdownToggle = params.dropdownToggle;
18
- },
19
-
20
- render: function () {
21
- // If nothing is checked, disable the parent element and return
22
- if (this.folderCount + this.itemCount + this.pickedCount === 0) {
23
- this.dropdownToggle.girderEnable(false);
24
- return;
25
- }
26
-
27
- this.dropdownToggle.girderEnable(true);
28
- this.$el.html(CheckedActionsMenuTemplate({
29
- minFolderLevel: this.minFolderLevel,
30
- minItemLevel: this.minItemLevel,
31
- folderCount: this.folderCount,
32
- itemCount: this.itemCount,
33
- AccessType: AccessType,
34
- pickedCount: this.pickedCount,
35
- pickedCopyAllowed: this.pickedCopyAllowed,
36
- pickedMoveAllowed: this.pickedMoveAllowed,
37
- pickedDesc: this.pickedDesc,
38
- HierarchyWidget: HierarchyWidget
39
- }));
40
-
41
- return this;
42
- },
43
-
44
- /**
45
- * This should be called when the checkbox selection changes. It will
46
- * update and re-render the checked action menu.
47
- * @param minLevel The minimum access level across the checked resource set.
48
- * @param folderCount The number of checked folders.
49
- * @param itemCount The number of checked items.
50
- */
51
- update: function (params) {
52
- this._fetchAndInit(params);
53
- this.render();
54
- },
55
-
56
- _fetchAndInit: function (params) {
57
- this.minFolderLevel = params.minFolderLevel || AccessType.READ;
58
- this.minItemLevel = params.minItemLevel || AccessType.READ;
59
- this.folderCount = params.folderCount || 0;
60
- this.itemCount = params.itemCount || 0;
61
- this.pickedCount = params.pickedCount || 0;
62
- this.pickedCopyAllowed = params.pickedCopyAllowed || false;
63
- this.pickedMoveAllowed = params.pickedMoveAllowed || false;
64
- this.pickedDesc = params.pickedDesc || '';
65
- }
66
- });
67
-
68
- export default CheckedMenuWidget;
@@ -1,40 +0,0 @@
1
- import View from '@girder/core/views/View';
2
- import { formatDate, DATE_SECOND, renderMarkdown, formatSize } from '@girder/core/misc';
3
-
4
- import CollectionInfoDialogTemplate from '@girder/core/templates/widgets/collectionInfoDialog.pug';
5
-
6
- import '@girder/core/utilities/jquery/girderModal';
7
-
8
- /**
9
- * This view shows a dialog containing detailed collection information.
10
- */
11
- var CollectionInfoWidget = View.extend({
12
- initialize: function () {
13
- this.needToFetch = !this.model.has('nFolders');
14
- if (this.needToFetch || this.timestamp !== this.model.get('updated')) {
15
- this.model.once('g:fetched.details', function () {
16
- this.needToFetch = false;
17
- this.timestamp = this.model.get('updated');
18
- this.render();
19
- }, this).fetch({ extraPath: 'details' });
20
- }
21
- },
22
-
23
- render: function () {
24
- if (this.needToFetch) {
25
- return;
26
- }
27
-
28
- this.$el.html(CollectionInfoDialogTemplate({
29
- collection: this.model,
30
- formatDate: formatDate,
31
- formatSize: formatSize,
32
- DATE_SECOND: DATE_SECOND,
33
- renderMarkdown: renderMarkdown
34
- })).girderModal(this);
35
-
36
- return this;
37
- }
38
- });
39
-
40
- export default CollectionInfoWidget;
@@ -1,179 +0,0 @@
1
- import _ from 'underscore';
2
- import moment from 'moment';
3
-
4
- import View from '@girder/core/views/View';
5
-
6
- import dateTimeRangeWidgetTemplate from '@girder/core/templates/widgets/dateTimeRangeWidget.pug';
7
-
8
- import 'eonasdan-bootstrap-datetimepicker'; // /src/js/bootstrap-datetimepicker.js'
9
- import 'eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css';
10
-
11
- /**
12
- * This widget provides text input fields to specify a range of dates/times.
13
- * That is, the first field specifies "from" and the second field specifies
14
- * "to." The user chooses each date/time using a popup picker.
15
- */
16
- var DateTimeRangeWidget = View.extend({
17
-
18
- /**
19
- * @param [settings.defaultFromDate=false] The default "from" date/time when
20
- * not set explicitly. Set to false to have no default.
21
- * @param [settings.defaultToDate=false] The default "to" date/time when not
22
- * set explicitly. Set to false to have no default.
23
- * @param [settings.showIcon=true] Whether to show calendar icons beside
24
- * the input fields. When true, clicking the icon shows the popup. Otherwise,
25
- * focusing the input field shows the popup.
26
- * @param [settings.fromLabel='Start date'] The label text for the "from"
27
- * input field.
28
- * @param [settings.toLabel='End date'] The label text for the "to" input
29
- * field.
30
- */
31
- initialize: function (settings) {
32
- this.defaultFromDate = settings.defaultFromDate || false;
33
- this.defaultToDate = settings.defaultToDate || false;
34
- this.showIcon = _.has(settings, 'showIcon') ? settings.showIcon : true;
35
- this.fromLabel = settings.fromLabel || 'Start date';
36
- this.toLabel = settings.toLabel || 'End date';
37
- },
38
-
39
- render: function () {
40
- this.$el.html(dateTimeRangeWidgetTemplate({
41
- showIcon: this.showIcon,
42
- fromLabel: this.fromLabel,
43
- toLabel: this.toLabel
44
- }));
45
-
46
- // Link datetimepickers to disallow choosing range where "from" date is
47
- // after "to" date
48
-
49
- var options = {
50
- showClear: true,
51
- showTodayButton: true,
52
- icons: {
53
- time: 'icon-clock',
54
- date: 'icon-calendar',
55
- up: 'icon-up-open',
56
- down: 'icon-down-open',
57
- previous: 'icon-left-open',
58
- next: 'icon-right-open',
59
- clear: 'icon-trash',
60
- close: 'icon-cancel',
61
- today: 'icon-target'
62
- }
63
- };
64
- options.useCurrent = 'day';
65
- options.defaultDate = this.defaultFromDate;
66
- this.$('.g-datetime-widget-from').datetimepicker(options);
67
-
68
- options.useCurrent = false;
69
- options.defaultDate = this.defaultToDate;
70
- this.$('.g-datetime-widget-to').datetimepicker(options);
71
-
72
- this.$('.g-datetime-widget-from').on('dp.change', (e) => {
73
- var picker = this._picker('.g-datetime-widget-to');
74
- picker.minDate(e.date);
75
- });
76
- this.$('.g-datetime-widget-to').on('dp.change', (e) => {
77
- var picker = this._picker('.g-datetime-widget-from');
78
- picker.maxDate(e.date);
79
- });
80
-
81
- return this;
82
- },
83
-
84
- /**
85
- * Set "from" date/time. Argument can be an ISO 8601-formatted date string,
86
- * a moment object, or a Date object. Call with null or the empty string to
87
- * clear. When called with a string, the widget displays in local time.
88
- *
89
- * @param date From date/time to display.
90
- */
91
- setFromDate: function (date) {
92
- this._setDate('.g-datetime-widget-from', date);
93
- },
94
-
95
- /**
96
- * Set "to" date/time. Argument can be an ISO 8601-formatted date string,
97
- * a moment object, or a Date object. Call with null or the empty string to
98
- * clear. When called with a string, the widget displays in local time.
99
- *
100
- * @param date To date/time to display.
101
- */
102
- setToDate: function (date) {
103
- this._setDate('.g-datetime-widget-to', date);
104
- },
105
-
106
- /*
107
- * Convenience function to set date/time for a specified datetimepicker.
108
- *
109
- * @param [id] Element ID on which to access the datetimepicker.
110
- */
111
- _setDate: function (id, date) {
112
- var picker = this._picker(id);
113
- if (_.isEmpty(date)) {
114
- picker.clear();
115
- } else if (_.isString(date)) {
116
- var localDate = moment.utc(date).local();
117
- picker.date(localDate);
118
- } else {
119
- picker.date(date);
120
- }
121
- },
122
-
123
- /**
124
- * Get the "from" date/time as a moment object in UTC. Returns null if no
125
- * date is set.
126
- */
127
- fromDate: function () {
128
- return this._date('.g-datetime-widget-from');
129
- },
130
-
131
- /**
132
- * Get the "to" date/time as a moment object in UTC. Returns null if no date
133
- * is set.
134
- */
135
- toDate: function () {
136
- return this._date('.g-datetime-widget-to');
137
- },
138
-
139
- /**
140
- * Convenience function to return "from" the date/time as a string in UTC.
141
- * Returns the empty string if no date is set.
142
- */
143
- fromDateString: function () {
144
- return this._dateString('.g-datetime-widget-from');
145
- },
146
-
147
- /**
148
- * Convenience function to return the "to" date/time as a string in UTC.
149
- * Returns the empty string if no date is set.
150
- */
151
- toDateString: function () {
152
- return this._dateString('.g-datetime-widget-to');
153
- },
154
-
155
- _picker: function (id) {
156
- var picker = this.$(id).data('DateTimePicker');
157
- return picker;
158
- },
159
-
160
- _date: function (id) {
161
- var picker = this._picker(id);
162
- var date = picker.date();
163
- if (date !== null) {
164
- date = moment(date);
165
- date.utc();
166
- }
167
- return date;
168
- },
169
-
170
- _dateString: function (id) {
171
- var date = this._date(id);
172
- if (date === null) {
173
- return '';
174
- }
175
- return date.format();
176
- }
177
- });
178
-
179
- export default DateTimeRangeWidget;