@girder/core 3.2.8 → 5.0.0-a6
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/README.md +61 -0
- package/package.json +79 -31
- package/assets/Girder_Mark.png +0 -0
- package/auth.js +0 -152
- package/collections/ApiKeyCollection.js +0 -9
- package/collections/AssetstoreCollection.js +0 -9
- package/collections/Collection.js +0 -295
- package/collections/CollectionCollection.js +0 -9
- package/collections/FileCollection.js +0 -11
- package/collections/FolderCollection.js +0 -11
- package/collections/GroupCollection.js +0 -9
- package/collections/ItemCollection.js +0 -11
- package/collections/UserCollection.js +0 -24
- package/collections/index.js +0 -21
- package/constants.js +0 -33
- package/dialog.js +0 -128
- package/events.js +0 -6
- package/index.js +0 -31
- package/main.js +0 -21
- package/misc.js +0 -260
- package/models/AccessControlledModel.js +0 -76
- package/models/ApiKeyModel.js +0 -31
- package/models/AssetstoreModel.js +0 -43
- package/models/CollectionCreationPolicyModel.js +0 -20
- package/models/CollectionModel.js +0 -12
- package/models/FileModel.js +0 -310
- package/models/FolderModel.js +0 -33
- package/models/GroupModel.js +0 -197
- package/models/ItemModel.js +0 -72
- package/models/MetadataMixin.js +0 -88
- package/models/Model.js +0 -187
- package/models/UserModel.js +0 -189
- package/models/index.js +0 -25
- package/pluginUtils.js +0 -11
- package/rest.js +0 -216
- package/router.js +0 -58
- package/routes.js +0 -231
- package/stylesheets/apidocs/apidocs.styl +0 -50
- package/stylesheets/body/adminConsole.styl +0 -21
- package/stylesheets/body/assetstores.styl +0 -46
- package/stylesheets/body/collectionList.styl +0 -39
- package/stylesheets/body/collectionPage.styl +0 -6
- package/stylesheets/body/frontPage.styl +0 -48
- package/stylesheets/body/groupList.styl +0 -43
- package/stylesheets/body/groupPage.styl +0 -116
- package/stylesheets/body/itemPage.styl +0 -81
- package/stylesheets/body/plugins.styl +0 -61
- package/stylesheets/body/searchResultsList.styl +0 -51
- package/stylesheets/body/systemConfig.styl +0 -56
- package/stylesheets/body/userAccount.styl +0 -57
- package/stylesheets/body/userList.styl +0 -79
- package/stylesheets/body/userPage.styl +0 -6
- package/stylesheets/layout/footer.styl +0 -19
- package/stylesheets/layout/global.styl +0 -154
- package/stylesheets/layout/globalNav.styl +0 -89
- package/stylesheets/layout/header.styl +0 -29
- package/stylesheets/layout/headerUser.styl +0 -33
- package/stylesheets/layout/layout.styl +0 -75
- package/stylesheets/layout/layoutVars.styl +0 -9
- package/stylesheets/layout/loading.styl +0 -37
- package/stylesheets/layout/progressArea.styl +0 -17
- package/stylesheets/widgets/accessWidget.styl +0 -106
- package/stylesheets/widgets/browserWidget.styl +0 -9
- package/stylesheets/widgets/hierarchyWidget.styl +0 -188
- package/stylesheets/widgets/markdownWidget.styl +0 -92
- package/stylesheets/widgets/metadataWidget.styl +0 -92
- package/stylesheets/widgets/searchFieldWidget.styl +0 -70
- package/stylesheets/widgets/taskProgress.styl +0 -41
- package/stylesheets/widgets/timelineWidget.styl +0 -41
- package/stylesheets/widgets/uploadWidget.styl +0 -43
- package/stylesheets/widgets/userOtpManagementWidget.styl +0 -159
- package/templates/body/adminConsole.pug +0 -13
- package/templates/body/assetstores.pug +0 -98
- package/templates/body/collectionList.pug +0 -40
- package/templates/body/collectionPage.pug +0 -36
- package/templates/body/filesystemImport.pug +0 -41
- package/templates/body/frontPage.pug +0 -83
- package/templates/body/groupList.pug +0 -30
- package/templates/body/groupPage.pug +0 -116
- package/templates/body/itemPage.pug +0 -61
- package/templates/body/plugins.pug +0 -20
- package/templates/body/s3Import.pug +0 -35
- package/templates/body/searchResults.pug +0 -15
- package/templates/body/searchResultsType.pug +0 -13
- package/templates/body/systemConfiguration.pug +0 -221
- package/templates/body/userAccount.pug +0 -83
- package/templates/body/userList.pug +0 -43
- package/templates/body/userPage.pug +0 -40
- package/templates/layout/alert.pug +0 -5
- package/templates/layout/layout.pug +0 -12
- package/templates/layout/layoutFooter.pug +0 -11
- package/templates/layout/layoutGlobalNav.pug +0 -7
- package/templates/layout/layoutHeader.pug +0 -8
- package/templates/layout/layoutHeaderUser.pug +0 -26
- package/templates/layout/layoutProgressArea.pug +0 -1
- package/templates/layout/loginDialog.pug +0 -30
- package/templates/layout/registerDialog.pug +0 -35
- package/templates/layout/resetPasswordDialog.pug +0 -25
- package/templates/widgets/accessEditor.pug +0 -23
- package/templates/widgets/accessEditorMixins.pug +0 -57
- package/templates/widgets/accessEditorNonModal.pug +0 -11
- package/templates/widgets/accessEntry.pug +0 -32
- package/templates/widgets/apiKeyList.pug +0 -50
- package/templates/widgets/browserWidget.pug +0 -32
- package/templates/widgets/checkedActionsMenu.pug +0 -46
- package/templates/widgets/collectionInfoDialog.pug +0 -37
- package/templates/widgets/confirmDialog.pug +0 -14
- package/templates/widgets/dateTimeRangeWidget.pug +0 -20
- package/templates/widgets/dateTimeWidget.pug +0 -8
- package/templates/widgets/editApiKeyWidget.pug +0 -43
- package/templates/widgets/editAssetstoreWidget.pug +0 -78
- package/templates/widgets/editCollectionWidget.pug +0 -27
- package/templates/widgets/editFileWidget.pug +0 -21
- package/templates/widgets/editFolderWidget.pug +0 -27
- package/templates/widgets/editGroupWidget.pug +0 -54
- package/templates/widgets/editItemWidget.pug +0 -27
- package/templates/widgets/fileInfoDialog.pug +0 -33
- package/templates/widgets/fileList.pug +0 -33
- package/templates/widgets/folderInfoDialog.pug +0 -42
- package/templates/widgets/folderList.pug +0 -21
- package/templates/widgets/groupAdminList.pug +0 -33
- package/templates/widgets/groupInviteDialog.pug +0 -76
- package/templates/widgets/groupInviteList.pug +0 -14
- package/templates/widgets/groupMemberList.pug +0 -39
- package/templates/widgets/groupModList.pug +0 -23
- package/templates/widgets/hierarchyBreadcrumb.pug +0 -37
- package/templates/widgets/hierarchyPaginated.pug +0 -19
- package/templates/widgets/hierarchyWidget.pug +0 -96
- package/templates/widgets/itemBreadcrumb.pug +0 -16
- package/templates/widgets/itemList.pug +0 -27
- package/templates/widgets/jsonMetadatumEditWidget.pug +0 -13
- package/templates/widgets/jsonMetadatumView.pug +0 -6
- package/templates/widgets/loadingAnimation.pug +0 -4
- package/templates/widgets/markdownWidget.pug +0 -34
- package/templates/widgets/metadataWidget.pug +0 -16
- package/templates/widgets/metadatumEditWidget.pug +0 -15
- package/templates/widgets/metadatumView.pug +0 -5
- package/templates/widgets/newAssetstore.pug +0 -118
- package/templates/widgets/paginateWidget.pug +0 -7
- package/templates/widgets/pluginConfigBreadcrumb.pug +0 -13
- package/templates/widgets/rootSelectorWidget.pug +0 -13
- package/templates/widgets/searchField.pug +0 -10
- package/templates/widgets/searchHelp.pug +0 -12
- package/templates/widgets/searchModeSelect.pug +0 -9
- package/templates/widgets/searchResults.pug +0 -14
- package/templates/widgets/sortCollectionWidget.pug +0 -14
- package/templates/widgets/taskProgress.pug +0 -16
- package/templates/widgets/timeline.pug +0 -15
- package/templates/widgets/uploadWidget.pug +0 -15
- package/templates/widgets/uploadWidgetMixins.pug +0 -31
- package/templates/widgets/uploadWidgetNonModal.pug +0 -10
- package/templates/widgets/userOtpBegin.pug +0 -4
- package/templates/widgets/userOtpDisable.pug +0 -6
- package/templates/widgets/userOtpEnable.pug +0 -44
- package/utilities/EventStream.js +0 -177
- package/utilities/PluginUtils.js +0 -36
- package/utilities/S3UploadHandler.js +0 -303
- package/utilities/index.js +0 -9
- package/utilities/jquery/girderEnable.js +0 -19
- package/utilities/jquery/girderModal.js +0 -48
- package/version.js +0 -10
- package/views/App.js +0 -359
- package/views/View.js +0 -78
- package/views/body/AdminView.js +0 -29
- package/views/body/AssetstoresView.js +0 -235
- package/views/body/CollectionView.js +0 -188
- package/views/body/CollectionsView.js +0 -120
- package/views/body/FilesystemImportView.js +0 -83
- package/views/body/FolderView.js +0 -54
- package/views/body/FrontPageView.js +0 -47
- package/views/body/GroupView.js +0 -336
- package/views/body/GroupsView.js +0 -106
- package/views/body/ItemView.js +0 -177
- package/views/body/PluginsView.js +0 -73
- package/views/body/S3ImportView.js +0 -80
- package/views/body/SearchResultsView.js +0 -162
- package/views/body/SystemConfigurationView.js +0 -196
- package/views/body/UserAccountView.js +0 -179
- package/views/body/UserView.js +0 -165
- package/views/body/UsersView.js +0 -124
- package/views/body/index.js +0 -37
- package/views/index.js +0 -13
- package/views/layout/FooterView.js +0 -29
- package/views/layout/GlobalNavView.js +0 -103
- package/views/layout/HeaderUserView.js +0 -45
- package/views/layout/HeaderView.js +0 -83
- package/views/layout/LoginView.js +0 -100
- package/views/layout/ProgressListView.js +0 -70
- package/views/layout/RegisterView.js +0 -101
- package/views/layout/ResetPasswordView.js +0 -70
- package/views/layout/index.js +0 -19
- package/views/widgets/AccessWidget.js +0 -427
- package/views/widgets/ApiKeyListWidget.js +0 -140
- package/views/widgets/BrowserWidget.js +0 -317
- package/views/widgets/CheckedMenuWidget.js +0 -68
- package/views/widgets/CollectionInfoWidget.js +0 -40
- package/views/widgets/DateTimeRangeWidget.js +0 -179
- package/views/widgets/DateTimeWidget.js +0 -109
- package/views/widgets/EditApiKeyWidget.js +0 -122
- package/views/widgets/EditAssetstoreWidget.js +0 -148
- package/views/widgets/EditCollectionWidget.js +0 -93
- package/views/widgets/EditFileWidget.js +0 -56
- package/views/widgets/EditFolderWidget.js +0 -116
- package/views/widgets/EditGroupWidget.js +0 -125
- package/views/widgets/EditItemWidget.js +0 -110
- package/views/widgets/FileInfoWidget.js +0 -26
- package/views/widgets/FileListWidget.js +0 -151
- package/views/widgets/FolderInfoWidget.js +0 -39
- package/views/widgets/FolderListWidget.js +0 -106
- package/views/widgets/GroupAdminsWidget.js +0 -88
- package/views/widgets/GroupInvitesWidget.js +0 -56
- package/views/widgets/GroupMembersWidget.js +0 -185
- package/views/widgets/GroupModsWidget.js +0 -77
- package/views/widgets/HierarchyWidget.js +0 -1097
- package/views/widgets/ItemBreadcrumbWidget.js +0 -38
- package/views/widgets/ItemListWidget.js +0 -345
- package/views/widgets/LoadingAnimation.js +0 -17
- package/views/widgets/MarkdownWidget.js +0 -217
- package/views/widgets/MetadataWidget.js +0 -504
- package/views/widgets/NewAssetstoreWidget.js +0 -81
- package/views/widgets/PaginateWidget.js +0 -37
- package/views/widgets/PluginConfigBreadcrumbWidget.js +0 -33
- package/views/widgets/RootSelectorWidget.js +0 -192
- package/views/widgets/SearchFieldWidget.js +0 -365
- package/views/widgets/SearchPaginateWidget.js +0 -149
- package/views/widgets/SortCollectionWidget.js +0 -53
- package/views/widgets/TaskProgressWidget.js +0 -91
- package/views/widgets/TimelineWidget.js +0 -155
- package/views/widgets/UploadWidget.js +0 -340
- package/views/widgets/UserOtpManagementWidget.js +0 -105
- 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;
|