adapt-authoring-ui 0.0.1
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/.eslintignore +2 -0
- package/.eslintrc +14 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +55 -0
- package/.github/ISSUE_TEMPLATE/config.yml +1 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +22 -0
- package/.github/dependabot.yml +11 -0
- package/.github/pull_request_template.md +25 -0
- package/.github/workflows/labelled_prs.yml +16 -0
- package/.github/workflows/new.yml +19 -0
- package/adapt-authoring.json +11 -0
- package/app/core/app.js +43 -0
- package/app/core/assets/adapt-learning-logo-outline.png +0 -0
- package/app/core/assets/adapt-learning-logo-white.png +0 -0
- package/app/core/assets/ajax-loader.gif +0 -0
- package/app/core/assets/favicon.png +0 -0
- package/app/core/assets/transparency-light.png +0 -0
- package/app/core/browserStorage.js +45 -0
- package/app/core/collections/apiCollection.js +74 -0
- package/app/core/collections/contentCollection.js +33 -0
- package/app/core/collections/contentPluginCollection.js +24 -0
- package/app/core/collections/tagsCollection.js +4 -0
- package/app/core/constants.js +10 -0
- package/app/core/helpers.js +375 -0
- package/app/core/index.hbs +192 -0
- package/app/core/l10n.js +33 -0
- package/app/core/less/_reset.less +43 -0
- package/app/core/less/app.less +100 -0
- package/app/core/less/buttons.less +268 -0
- package/app/core/less/colourLabels.less +14 -0
- package/app/core/less/colours.less +132 -0
- package/app/core/less/columns.less +190 -0
- package/app/core/less/fonts.less +30 -0
- package/app/core/less/forms.less +77 -0
- package/app/core/less/sharedStyles.less +73 -0
- package/app/core/less/tables.less +29 -0
- package/app/core/less/tags.less +194 -0
- package/app/core/loading.hbs +27 -0
- package/app/core/models/articleModel.js +19 -0
- package/app/core/models/blockModel.js +25 -0
- package/app/core/models/clipboardModel.js +10 -0
- package/app/core/models/componentModel.js +18 -0
- package/app/core/models/configModel.js +22 -0
- package/app/core/models/contentModel.js +26 -0
- package/app/core/models/contentObjectModel.js +19 -0
- package/app/core/models/contentPluginModel.js +10 -0
- package/app/core/models/courseModel.js +24 -0
- package/app/core/models/sessionModel.js +86 -0
- package/app/core/origin.js +189 -0
- package/app/core/router.js +135 -0
- package/app/core/views/originView.js +92 -0
- package/app/libraries/babel-polyfill.min.js +1 -0
- package/app/libraries/backbone-forms-lists.js +669 -0
- package/app/libraries/backbone-forms.js +2604 -0
- package/app/libraries/backbone.js +1581 -0
- package/app/libraries/ckeditor.js +6 -0
- package/app/libraries/handlebars.js +4902 -0
- package/app/libraries/imageReady.js +2 -0
- package/app/libraries/inview.js +140 -0
- package/app/libraries/jquery-ui.min.js +6 -0
- package/app/libraries/jquery.form.js +1277 -0
- package/app/libraries/jquery.js +10346 -0
- package/app/libraries/jquery.tagsinput.min.js +1 -0
- package/app/libraries/moment.min.js +7 -0
- package/app/libraries/polyglot.min.js +2922 -0
- package/app/libraries/require.js +36 -0
- package/app/libraries/scrollTo.js +11 -0
- package/app/libraries/selectize/css/selectize.less +403 -0
- package/app/libraries/selectize/js/selectize.js +4500 -0
- package/app/libraries/spectrum/spectrum.js +2323 -0
- package/app/libraries/spectrum/spectrum.less +507 -0
- package/app/libraries/underscore.js +1692 -0
- package/app/libraries/velocity.js +4773 -0
- package/app/modules/appHeader/assets/top-bar-1080.jpg +0 -0
- package/app/modules/appHeader/assets/top-bar-2560.jpg +0 -0
- package/app/modules/appHeader/index.js +5 -0
- package/app/modules/appHeader/less/appHeader.less +72 -0
- package/app/modules/appHeader/templates/appHeader.hbs +17 -0
- package/app/modules/appHeader/views/appHeaderView.js +63 -0
- package/app/modules/assetManagement/collections/assetCollection.js +16 -0
- package/app/modules/assetManagement/index.js +65 -0
- package/app/modules/assetManagement/less/asset.less +229 -0
- package/app/modules/assetManagement/less/assetManagementModalTags.less +34 -0
- package/app/modules/assetManagement/less/assetManagementNew.less +60 -0
- package/app/modules/assetManagement/models/assetModel.js +11 -0
- package/app/modules/assetManagement/templates/assetManagement.hbs +12 -0
- package/app/modules/assetManagement/templates/assetManagementCollection.hbs +2 -0
- package/app/modules/assetManagement/templates/assetManagementEditAsset.hbs +9 -0
- package/app/modules/assetManagement/templates/assetManagementEditAssetSidebar.hbs +10 -0
- package/app/modules/assetManagement/templates/assetManagementListItem.hbs +35 -0
- package/app/modules/assetManagement/templates/assetManagementModalAutofill.hbs +1 -0
- package/app/modules/assetManagement/templates/assetManagementModalEditAsset.hbs +11 -0
- package/app/modules/assetManagement/templates/assetManagementModalFilters.hbs +16 -0
- package/app/modules/assetManagement/templates/assetManagementModalTags.hbs +26 -0
- package/app/modules/assetManagement/templates/assetManagementPreview.hbs +53 -0
- package/app/modules/assetManagement/templates/assetManagementSidebar.hbs +93 -0
- package/app/modules/assetManagement/templates/assetPicker.hbs +45 -0
- package/app/modules/assetManagement/views/assetManagementCollectionView.js +216 -0
- package/app/modules/assetManagement/views/assetManagementEditAssetSidebarView.js +25 -0
- package/app/modules/assetManagement/views/assetManagementEditAssetView.js +123 -0
- package/app/modules/assetManagement/views/assetManagementItemView.js +68 -0
- package/app/modules/assetManagement/views/assetManagementModalAutofillView.js +51 -0
- package/app/modules/assetManagement/views/assetManagementModalEditAssetView.js +38 -0
- package/app/modules/assetManagement/views/assetManagementModalFiltersView.js +132 -0
- package/app/modules/assetManagement/views/assetManagementModalTagsView.js +169 -0
- package/app/modules/assetManagement/views/assetManagementModalView.js +62 -0
- package/app/modules/assetManagement/views/assetManagementPreviewView.js +69 -0
- package/app/modules/assetManagement/views/assetManagementSidebarView.js +126 -0
- package/app/modules/assetManagement/views/assetManagementView.js +43 -0
- package/app/modules/colorLabel/index.js +48 -0
- package/app/modules/colorLabel/less/colorLabels.less +102 -0
- package/app/modules/colorLabel/models/colors.js +31 -0
- package/app/modules/colorLabel/templates/colorLabelPopUpView.hbs +21 -0
- package/app/modules/colorLabel/views/colorLabelPopupView.js +75 -0
- package/app/modules/contentHeader/index.js +6 -0
- package/app/modules/contentHeader/less/contentHeader.less +152 -0
- package/app/modules/contentHeader/less/options.less +51 -0
- package/app/modules/contentHeader/templates/actionsButton.hbs +3 -0
- package/app/modules/contentHeader/templates/contentHeader.hbs +38 -0
- package/app/modules/contentHeader/templates/contentHeaderToggleButton.hbs +11 -0
- package/app/modules/contentHeader/templates/filterItem.hbs +23 -0
- package/app/modules/contentHeader/templates/options.hbs +14 -0
- package/app/modules/contentHeader/templates/partials/part_headerButtonContent.hbs +2 -0
- package/app/modules/contentHeader/templates/sortItem.hbs +9 -0
- package/app/modules/contentHeader/views/actionsButtonView.js +14 -0
- package/app/modules/contentHeader/views/contentHeaderButtonView.js +42 -0
- package/app/modules/contentHeader/views/contentHeaderToggleButtonView.js +52 -0
- package/app/modules/contentHeader/views/contentHeaderView.js +96 -0
- package/app/modules/contentHeader/views/filtersButtonView.js +31 -0
- package/app/modules/contentHeader/views/optionsView.js +88 -0
- package/app/modules/contentHeader/views/sortsButtonView.js +45 -0
- package/app/modules/contentPane/index.js +20 -0
- package/app/modules/contentPane/less/contentPane.less +8 -0
- package/app/modules/contentPane/templates/contentPane.hbs +2 -0
- package/app/modules/contentPane/views/contentPaneView.js +77 -0
- package/app/modules/contextMenu/index.js +85 -0
- package/app/modules/contextMenu/less/contextMenu.less +54 -0
- package/app/modules/contextMenu/templates/contextMenu.hbs +6 -0
- package/app/modules/contextMenu/templates/contextMenuItem.hbs +8 -0
- package/app/modules/contextMenu/views/contextMenuItemView.js +37 -0
- package/app/modules/contextMenu/views/contextMenuView.js +76 -0
- package/app/modules/editor/article/index.js +18 -0
- package/app/modules/editor/article/templates/editorArticleEdit.hbs +2 -0
- package/app/modules/editor/article/templates/editorArticleEditSidebar.hbs +19 -0
- package/app/modules/editor/article/views/editorArticleEditSidebarView.js +32 -0
- package/app/modules/editor/article/views/editorArticleEditView.js +19 -0
- package/app/modules/editor/block/index.js +18 -0
- package/app/modules/editor/block/templates/editorBlockEdit.hbs +2 -0
- package/app/modules/editor/block/templates/editorBlockEditSidebar.hbs +19 -0
- package/app/modules/editor/block/views/editorBlockEditSidebarView.js +28 -0
- package/app/modules/editor/block/views/editorBlockEditView.js +19 -0
- package/app/modules/editor/component/index.js +22 -0
- package/app/modules/editor/component/templates/editorComponentEdit.hbs +2 -0
- package/app/modules/editor/component/templates/editorComponentEditSidebar.hbs +19 -0
- package/app/modules/editor/component/views/editorComponentEditSidebarView.js +32 -0
- package/app/modules/editor/component/views/editorComponentEditView.js +23 -0
- package/app/modules/editor/config/index.js +15 -0
- package/app/modules/editor/config/templates/editorConfigEdit.hbs +1 -0
- package/app/modules/editor/config/templates/editorConfigEditSidebar.hbs +10 -0
- package/app/modules/editor/config/views/editorConfigEditSidebarView.js +28 -0
- package/app/modules/editor/config/views/editorConfigEditView.js +28 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-accordion.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-assessment.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-blank.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-default.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-gmcq.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-graphic.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-hot-graphic.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-matching.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-mcq.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-media.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-narrative.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-slider.png +0 -0
- package/app/modules/editor/contentObject/assets/component-icons/icon-text.png +0 -0
- package/app/modules/editor/contentObject/index.js +68 -0
- package/app/modules/editor/contentObject/less/editing-overlay-component-list.less +60 -0
- package/app/modules/editor/contentObject/less/editing-overlay-panel.less +25 -0
- package/app/modules/editor/contentObject/less/editorMenu.less +84 -0
- package/app/modules/editor/contentObject/less/editorMenuItem.less +114 -0
- package/app/modules/editor/contentObject/less/editorMenuLayer.less +70 -0
- package/app/modules/editor/contentObject/less/editorPage.less +162 -0
- package/app/modules/editor/contentObject/less/editorPageArticle.less +40 -0
- package/app/modules/editor/contentObject/less/editorPageBlock.less +33 -0
- package/app/modules/editor/contentObject/less/editorPageComponent.less +47 -0
- package/app/modules/editor/contentObject/less/editorPageComponentList.less +234 -0
- package/app/modules/editor/contentObject/templates/editorMenu.hbs +1 -0
- package/app/modules/editor/contentObject/templates/editorMenuItem.hbs +23 -0
- package/app/modules/editor/contentObject/templates/editorMenuLayer.hbs +12 -0
- package/app/modules/editor/contentObject/templates/editorMenuSidebar.hbs +1 -0
- package/app/modules/editor/contentObject/templates/editorPage.hbs +15 -0
- package/app/modules/editor/contentObject/templates/editorPageArticle.hbs +15 -0
- package/app/modules/editor/contentObject/templates/editorPageBlock.hbs +14 -0
- package/app/modules/editor/contentObject/templates/editorPageComponent.hbs +9 -0
- package/app/modules/editor/contentObject/templates/editorPageComponentList.hbs +33 -0
- package/app/modules/editor/contentObject/templates/editorPageComponentListItem.hbs +24 -0
- package/app/modules/editor/contentObject/templates/editorPageComponentPasteZone.hbs +4 -0
- package/app/modules/editor/contentObject/templates/editorPageEdit.hbs +1 -0
- package/app/modules/editor/contentObject/templates/editorPageEditSidebar.hbs +10 -0
- package/app/modules/editor/contentObject/templates/editorPageSidebar.hbs +1 -0
- package/app/modules/editor/contentObject/views/editorMenuItemView.js +174 -0
- package/app/modules/editor/contentObject/views/editorMenuLayerView.js +212 -0
- package/app/modules/editor/contentObject/views/editorMenuSidebarView.js +13 -0
- package/app/modules/editor/contentObject/views/editorMenuView.js +211 -0
- package/app/modules/editor/contentObject/views/editorPageArticleView.js +278 -0
- package/app/modules/editor/contentObject/views/editorPageBlockView.js +280 -0
- package/app/modules/editor/contentObject/views/editorPageComponentListItemView.js +80 -0
- package/app/modules/editor/contentObject/views/editorPageComponentListView.js +131 -0
- package/app/modules/editor/contentObject/views/editorPageComponentPasteZoneView.js +47 -0
- package/app/modules/editor/contentObject/views/editorPageComponentView.js +202 -0
- package/app/modules/editor/contentObject/views/editorPageEditSidebarView.js +28 -0
- package/app/modules/editor/contentObject/views/editorPageEditView.js +19 -0
- package/app/modules/editor/contentObject/views/editorPageSidebarView.js +13 -0
- package/app/modules/editor/contentObject/views/editorPageView.js +183 -0
- package/app/modules/editor/course/index.js +26 -0
- package/app/modules/editor/course/templates/editorCourseEdit.hbs +2 -0
- package/app/modules/editor/course/templates/editorCourseEditSidebar.hbs +19 -0
- package/app/modules/editor/course/views/editorCourseEditSidebarView.js +28 -0
- package/app/modules/editor/course/views/editorCourseEditView.js +56 -0
- package/app/modules/editor/extensions/index.js +26 -0
- package/app/modules/editor/extensions/less/extensions.less +22 -0
- package/app/modules/editor/extensions/templates/editorExtensionsEdit.hbs +85 -0
- package/app/modules/editor/extensions/templates/editorExtensionsEditSidebar.hbs +1 -0
- package/app/modules/editor/extensions/views/editorExtensionsEditSidebarView.js +10 -0
- package/app/modules/editor/extensions/views/editorExtensionsEditView.js +85 -0
- package/app/modules/editor/global/collections/editorCollection.js +24 -0
- package/app/modules/editor/global/editorDataLoader.js +91 -0
- package/app/modules/editor/global/helpers.js +99 -0
- package/app/modules/editor/global/less/colorLabels.less +55 -0
- package/app/modules/editor/global/less/editor.less +204 -0
- package/app/modules/editor/global/templates/editor.hbs +1 -0
- package/app/modules/editor/global/templates/editorPasteZone.hbs +4 -0
- package/app/modules/editor/global/templates/partials/part_editorCommon.hbs +70 -0
- package/app/modules/editor/global/templates/partials/part_editorItemSidebar.hbs +40 -0
- package/app/modules/editor/global/templates/partials/part_editorMenu.hbs +4 -0
- package/app/modules/editor/global/templates/partials/part_settingsGeneral.hbs +27 -0
- package/app/modules/editor/global/views/editorOriginView.js +255 -0
- package/app/modules/editor/global/views/editorPasteZoneView.js +69 -0
- package/app/modules/editor/global/views/editorView.js +288 -0
- package/app/modules/editor/index.js +52 -0
- package/app/modules/editor/menuSettings/index.js +27 -0
- package/app/modules/editor/menuSettings/less/menusettings.less +55 -0
- package/app/modules/editor/menuSettings/templates/editorMenuSettingsEdit.hbs +1 -0
- package/app/modules/editor/menuSettings/templates/editorMenuSettingsEditSidebar.hbs +5 -0
- package/app/modules/editor/menuSettings/templates/editorMenuSettingsItem.hbs +4 -0
- package/app/modules/editor/menuSettings/views/editorMenuSettingsEditSidebarView.js +21 -0
- package/app/modules/editor/menuSettings/views/editorMenuSettingsEditView.js +71 -0
- package/app/modules/editor/menuSettings/views/editorMenuSettingsView.js +44 -0
- package/app/modules/editor/themeEditor/collections/editorPresetCollection.js +13 -0
- package/app/modules/editor/themeEditor/index.js +15 -0
- package/app/modules/editor/themeEditor/less/editorPresetEdit.less +78 -0
- package/app/modules/editor/themeEditor/less/editorTheming.less +73 -0
- package/app/modules/editor/themeEditor/models/editorModel.js +62 -0
- package/app/modules/editor/themeEditor/models/editorPresetModel.js +6 -0
- package/app/modules/editor/themeEditor/templates/editorPresetEdit.hbs +31 -0
- package/app/modules/editor/themeEditor/templates/editorTheming.hbs +35 -0
- package/app/modules/editor/themeEditor/templates/editorThemingSidebar.hbs +23 -0
- package/app/modules/editor/themeEditor/views/editorPresetEditView.js +98 -0
- package/app/modules/editor/themeEditor/views/editorThemingSidebarView.js +62 -0
- package/app/modules/editor/themeEditor/views/editorThemingView.js +304 -0
- package/app/modules/frameworkImport/index.js +32 -0
- package/app/modules/frameworkImport/less/frameworkImport.less +101 -0
- package/app/modules/frameworkImport/templates/frameworkImport.hbs +58 -0
- package/app/modules/frameworkImport/templates/frameworkImportSidebar.hbs +12 -0
- package/app/modules/frameworkImport/templates/frameworkImportSummary.hbs +40 -0
- package/app/modules/frameworkImport/templates/partials/part_frameworkImportButton.hbs +3 -0
- package/app/modules/frameworkImport/templates/partials/part_frameworkImportStatusMessages.hbs +22 -0
- package/app/modules/frameworkImport/views/frameworkImportSidebarView.js +31 -0
- package/app/modules/frameworkImport/views/frameworkImportView.js +109 -0
- package/app/modules/globalMenu/index.js +86 -0
- package/app/modules/globalMenu/less/globalMenu.less +117 -0
- package/app/modules/globalMenu/templates/globalMenu.hbs +6 -0
- package/app/modules/globalMenu/templates/globalMenuItem.hbs +10 -0
- package/app/modules/globalMenu/templates/partials/part_globalMenuButton.hbs +7 -0
- package/app/modules/globalMenu/views/globalMenuItemView.js +108 -0
- package/app/modules/globalMenu/views/globalMenuView.js +45 -0
- package/app/modules/limiteduser/index.js +17 -0
- package/app/modules/limiteduser/less/limitedUser.less +29 -0
- package/app/modules/limiteduser/templates/limitedUser.hbs +8 -0
- package/app/modules/limiteduser/views/limitedUserView.js +12 -0
- package/app/modules/modal/index.js +13 -0
- package/app/modules/modal/less/modal.less +61 -0
- package/app/modules/modal/models/modalModel.js +14 -0
- package/app/modules/modal/templates/modal.hbs +34 -0
- package/app/modules/modal/views/modalView.js +102 -0
- package/app/modules/notify/index.js +32 -0
- package/app/modules/notify/plugins/alert/assets/sweetalert.css +932 -0
- package/app/modules/notify/plugins/alert/index.js +117 -0
- package/app/modules/notify/plugins/alert/less/alert.less +74 -0
- package/app/modules/notify/plugins/alert/sweetalert2-11.1.7.all.min.js +2 -0
- package/app/modules/notify/plugins/console/index.js +18 -0
- package/app/modules/notify/plugins/snackbar/index.js +69 -0
- package/app/modules/notify/plugins/snackbar/less/snackbar.less +40 -0
- package/app/modules/notify/plugins/toast/index.js +70 -0
- package/app/modules/notify/plugins/toast/less/toast.less +62 -0
- package/app/modules/pluginManagement/index.js +36 -0
- package/app/modules/pluginManagement/less/pluginManagement.less +23 -0
- package/app/modules/pluginManagement/less/pluginType.less +25 -0
- package/app/modules/pluginManagement/templates/pluginManagement.hbs +43 -0
- package/app/modules/pluginManagement/templates/pluginManagementSidebar.hbs +40 -0
- package/app/modules/pluginManagement/templates/pluginManagementUpload.hbs +12 -0
- package/app/modules/pluginManagement/templates/pluginManagementUploadSidebar.hbs +13 -0
- package/app/modules/pluginManagement/templates/pluginType.hbs +43 -0
- package/app/modules/pluginManagement/views/pluginManagementSidebarView.js +48 -0
- package/app/modules/pluginManagement/views/pluginManagementUploadSidebarView.js +25 -0
- package/app/modules/pluginManagement/views/pluginManagementUploadView.js +52 -0
- package/app/modules/pluginManagement/views/pluginManagementView.js +104 -0
- package/app/modules/pluginManagement/views/pluginTypeView.js +105 -0
- package/app/modules/projects/assets/origami-project.jpg +0 -0
- package/app/modules/projects/index.js +82 -0
- package/app/modules/projects/less/projects.less +152 -0
- package/app/modules/projects/less/qproject.less +143 -0
- package/app/modules/projects/templates/project.hbs +63 -0
- package/app/modules/projects/templates/projects.hbs +6 -0
- package/app/modules/projects/templates/projectsSidebar.hbs +42 -0
- package/app/modules/projects/views/projectView.js +167 -0
- package/app/modules/projects/views/projectsSidebarView.js +172 -0
- package/app/modules/projects/views/projectsView.js +271 -0
- package/app/modules/scaffold/backboneFormsOverrides.js +284 -0
- package/app/modules/scaffold/index.js +342 -0
- package/app/modules/scaffold/lang/en.json +9 -0
- package/app/modules/scaffold/less/codeEditor.less +6 -0
- package/app/modules/scaffold/less/colourPicker.less +141 -0
- package/app/modules/scaffold/less/displayTitle.less +17 -0
- package/app/modules/scaffold/less/forms.less +174 -0
- package/app/modules/scaffold/less/list.less +35 -0
- package/app/modules/scaffold/less/modal.less +45 -0
- package/app/modules/scaffold/less/scaffoldAsset.less +23 -0
- package/app/modules/scaffold/less/scaffoldAssetItem.less +50 -0
- package/app/modules/scaffold/less/selectize.less +29 -0
- package/app/modules/scaffold/less/textArea.less +9 -0
- package/app/modules/scaffold/less/users.less +6 -0
- package/app/modules/scaffold/templates/field.hbs +25 -0
- package/app/modules/scaffold/templates/fieldset.hbs +10 -0
- package/app/modules/scaffold/templates/form.hbs +6 -0
- package/app/modules/scaffold/templates/list.hbs +4 -0
- package/app/modules/scaffold/templates/listItem.hbs +5 -0
- package/app/modules/scaffold/templates/scaffoldAsset.hbs +65 -0
- package/app/modules/scaffold/templates/scaffoldAssetItem.hbs +35 -0
- package/app/modules/scaffold/templates/scaffoldDisplayTitle.hbs +8 -0
- package/app/modules/scaffold/templates/scaffoldEditHtml.hbs +1 -0
- package/app/modules/scaffold/templates/scaffoldFile.hbs +1 -0
- package/app/modules/scaffold/templates/scaffoldItemsModal.hbs +14 -0
- package/app/modules/scaffold/templates/scaffoldModalOverlay.hbs +1 -0
- package/app/modules/scaffold/templates/scaffoldUsersOption.hbs +8 -0
- package/app/modules/scaffold/views/scaffoldAssetItemView.js +203 -0
- package/app/modules/scaffold/views/scaffoldAssetView.js +157 -0
- package/app/modules/scaffold/views/scaffoldCodeEditorView.js +64 -0
- package/app/modules/scaffold/views/scaffoldColourPickerView.js +70 -0
- package/app/modules/scaffold/views/scaffoldDisplayTitleView.js +112 -0
- package/app/modules/scaffold/views/scaffoldFileView.js +18 -0
- package/app/modules/scaffold/views/scaffoldItemsModalView.js +100 -0
- package/app/modules/scaffold/views/scaffoldListView.js +158 -0
- package/app/modules/scaffold/views/scaffoldTagsView.js +71 -0
- package/app/modules/scaffold/views/scaffoldUsersView.js +89 -0
- package/app/modules/sidebar/index.js +22 -0
- package/app/modules/sidebar/less/sidebar.less +298 -0
- package/app/modules/sidebar/less/sidebarFilter.less +91 -0
- package/app/modules/sidebar/templates/sidebar.hbs +7 -0
- package/app/modules/sidebar/templates/sidebarBreadcrumb.hbs +3 -0
- package/app/modules/sidebar/templates/sidebarDivide.hbs +5 -0
- package/app/modules/sidebar/templates/sidebarFieldsetFilter.hbs +6 -0
- package/app/modules/sidebar/templates/sidebarFilter.hbs +30 -0
- package/app/modules/sidebar/templates/sidebarRowFilter.hbs +4 -0
- package/app/modules/sidebar/templates/sidebarUpdateButton.hbs +3 -0
- package/app/modules/sidebar/views/sidebarFieldsetFilterView.js +43 -0
- package/app/modules/sidebar/views/sidebarFilterView.js +132 -0
- package/app/modules/sidebar/views/sidebarItemView.js +172 -0
- package/app/modules/sidebar/views/sidebarView.js +71 -0
- package/app/modules/user/assets/adapt-learning-logo.png +0 -0
- package/app/modules/user/assets/adapt-logo.png +0 -0
- package/app/modules/user/assets/login_bg.jpg +0 -0
- package/app/modules/user/index.js +75 -0
- package/app/modules/user/less/forgotPassword.less +14 -0
- package/app/modules/user/less/login.less +138 -0
- package/app/modules/user/less/logout.less +3 -0
- package/app/modules/user/less/resetPassword.less +7 -0
- package/app/modules/user/less/userProfile.less +49 -0
- package/app/modules/user/models/userProfileModel.js +32 -0
- package/app/modules/user/templates/forgotPassword.hbs +36 -0
- package/app/modules/user/templates/login.hbs +29 -0
- package/app/modules/user/templates/resetPassword.hbs +29 -0
- package/app/modules/user/templates/userProfile.hbs +71 -0
- package/app/modules/user/templates/userProfileSidebar.hbs +16 -0
- package/app/modules/user/views/forgotPasswordView.js +63 -0
- package/app/modules/user/views/loginView.js +93 -0
- package/app/modules/user/views/resetPasswordView.js +78 -0
- package/app/modules/user/views/userProfileSidebarView.js +32 -0
- package/app/modules/user/views/userProfileView.js +107 -0
- package/app/modules/userManagement/collections/userCollection.js +65 -0
- package/app/modules/userManagement/helpers.js +46 -0
- package/app/modules/userManagement/index.js +67 -0
- package/app/modules/userManagement/less/userManagement.less +268 -0
- package/app/modules/userManagement/models/userModel.js +34 -0
- package/app/modules/userManagement/templates/addUser.hbs +35 -0
- package/app/modules/userManagement/templates/addUserSidebar.hbs +9 -0
- package/app/modules/userManagement/templates/user.hbs +126 -0
- package/app/modules/userManagement/templates/userManagement.hbs +49 -0
- package/app/modules/userManagement/templates/userManagementFilter.hbs +19 -0
- package/app/modules/userManagement/templates/userManagementSidebar.hbs +13 -0
- package/app/modules/userManagement/views/addUserSidebarView.js +25 -0
- package/app/modules/userManagement/views/addUserView.js +85 -0
- package/app/modules/userManagement/views/filterView.js +49 -0
- package/app/modules/userManagement/views/userManagementSidebarView.js +33 -0
- package/app/modules/userManagement/views/userManagementView.js +104 -0
- package/app/modules/userManagement/views/userView.js +324 -0
- package/conf/config.schema.json +18 -0
- package/docs/migrating-from-legacy.md +19 -0
- package/docs/plugins/index-ui.md +17 -0
- package/docs/plugins/uidocs.js +54 -0
- package/docs/ui-extensions.md +15 -0
- package/index.js +1 -0
- package/lib/UiBuild.js +391 -0
- package/lib/UiModule.js +158 -0
- package/npm_hooks/postinstall.js +4 -0
- package/package.json +27 -0
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
define(['jquery', 'underscore', 'backbone', 'backboneForms'], function($, _, Backbone) {
|
|
2
|
+
|
|
3
|
+
;(function(Form) {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* List editor
|
|
7
|
+
*
|
|
8
|
+
* An array editor. Creates a list of other editor items.
|
|
9
|
+
*
|
|
10
|
+
* Special options:
|
|
11
|
+
* @param {String} [options.schema.itemType] The editor type for each item in the list. Default: 'Text'
|
|
12
|
+
* @param {String} [options.schema.confirmDelete] Text to display in a delete confirmation dialog. If falsey, will not ask for confirmation.
|
|
13
|
+
*/
|
|
14
|
+
Form.editors.List = Form.editors.Base.extend({
|
|
15
|
+
|
|
16
|
+
events: {
|
|
17
|
+
'click [data-action="add"]': function(event) {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
this.addItem(undefined, true);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
initialize: function(options) {
|
|
24
|
+
options = options || {};
|
|
25
|
+
|
|
26
|
+
var editors = Form.editors;
|
|
27
|
+
|
|
28
|
+
editors.Base.prototype.initialize.call(this, options);
|
|
29
|
+
|
|
30
|
+
var schema = this.schema;
|
|
31
|
+
if (!schema) throw new Error("Missing required option 'schema'");
|
|
32
|
+
|
|
33
|
+
this.schema = _.extend({
|
|
34
|
+
addLabel: 'Add'
|
|
35
|
+
}, schema);
|
|
36
|
+
|
|
37
|
+
this.template = options.template || schema.listTemplate || this.constructor.template;
|
|
38
|
+
|
|
39
|
+
//Determine the editor to use
|
|
40
|
+
this.Editor = (function() {
|
|
41
|
+
var type = schema.itemType;
|
|
42
|
+
|
|
43
|
+
//Default to Text
|
|
44
|
+
if (!type) return editors.Text;
|
|
45
|
+
|
|
46
|
+
//Use List-specific version if available
|
|
47
|
+
if (editors.List[type]) return editors.List[type];
|
|
48
|
+
|
|
49
|
+
//Or whichever was passed
|
|
50
|
+
return (_.isString(type)) ? editors[type] : type;
|
|
51
|
+
})();
|
|
52
|
+
|
|
53
|
+
this.ListItem = schema.itemClass || editors.List.Item;
|
|
54
|
+
|
|
55
|
+
this.items = [];
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
render: function() {
|
|
59
|
+
var self = this,
|
|
60
|
+
value = this.value || [],
|
|
61
|
+
$ = Backbone.$;
|
|
62
|
+
|
|
63
|
+
//Create main element
|
|
64
|
+
var $el = $($.trim(this.template({
|
|
65
|
+
addLabel: this.schema.addLabel
|
|
66
|
+
})));
|
|
67
|
+
|
|
68
|
+
//Store a reference to the list (item container)
|
|
69
|
+
this.$list = $el.is('[data-items]') ? $el : $el.find('[data-items]');
|
|
70
|
+
|
|
71
|
+
//Add existing items
|
|
72
|
+
if (value.length) {
|
|
73
|
+
_.each(value, function(itemValue) {
|
|
74
|
+
self.addItem(itemValue);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//If no existing items create an empty one, unless the editor specifies otherwise
|
|
79
|
+
else {
|
|
80
|
+
if (!this.Editor.isAsync) this.addItem();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
this.setElement($el);
|
|
84
|
+
this.$el.attr('id', this.id);
|
|
85
|
+
this.$el.attr('name', this.key);
|
|
86
|
+
|
|
87
|
+
if (this.hasFocus) this.trigger('blur', this);
|
|
88
|
+
|
|
89
|
+
return this;
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Add a new item to the list
|
|
94
|
+
* @param {Mixed} [value] Value for the new item editor
|
|
95
|
+
* @param {Boolean} [userInitiated] If the item was added by the user clicking 'add'
|
|
96
|
+
*/
|
|
97
|
+
addItem: function(value, userInitiated) {
|
|
98
|
+
var self = this,
|
|
99
|
+
editors = Form.editors;
|
|
100
|
+
|
|
101
|
+
//Create the item
|
|
102
|
+
var item = new this.ListItem({
|
|
103
|
+
list: this,
|
|
104
|
+
form: this.form,
|
|
105
|
+
schema: this.schema,
|
|
106
|
+
value: value,
|
|
107
|
+
Editor: this.Editor,
|
|
108
|
+
key: this.key
|
|
109
|
+
}).render();
|
|
110
|
+
|
|
111
|
+
var _addItem = function() {
|
|
112
|
+
self.items.push(item);
|
|
113
|
+
self.$list.append(item.el);
|
|
114
|
+
|
|
115
|
+
item.editor.on('all', function(event) {
|
|
116
|
+
if (event === 'change') return;
|
|
117
|
+
|
|
118
|
+
// args = ["key:change", itemEditor, fieldEditor]
|
|
119
|
+
var args = _.toArray(arguments);
|
|
120
|
+
args[0] = 'item:' + event;
|
|
121
|
+
args.splice(1, 0, self);
|
|
122
|
+
// args = ["item:key:change", this=listEditor, itemEditor, fieldEditor]
|
|
123
|
+
|
|
124
|
+
editors.List.prototype.trigger.apply(this, args);
|
|
125
|
+
}, self);
|
|
126
|
+
|
|
127
|
+
item.editor.on('change', function() {
|
|
128
|
+
if (!item.addEventTriggered) {
|
|
129
|
+
item.addEventTriggered = true;
|
|
130
|
+
this.trigger('add', this, item.editor);
|
|
131
|
+
}
|
|
132
|
+
this.trigger('item:change', this, item.editor);
|
|
133
|
+
this.trigger('change', this);
|
|
134
|
+
}, self);
|
|
135
|
+
|
|
136
|
+
item.editor.on('focus', function() {
|
|
137
|
+
if (this.hasFocus) return;
|
|
138
|
+
this.trigger('focus', this);
|
|
139
|
+
}, self);
|
|
140
|
+
item.editor.on('blur', function() {
|
|
141
|
+
if (!this.hasFocus) return;
|
|
142
|
+
var self = this;
|
|
143
|
+
setTimeout(function() {
|
|
144
|
+
if (_.find(self.items, function(item) { return item.editor.hasFocus; })) return;
|
|
145
|
+
self.trigger('blur', self);
|
|
146
|
+
}, 0);
|
|
147
|
+
}, self);
|
|
148
|
+
|
|
149
|
+
if (userInitiated || value) {
|
|
150
|
+
item.addEventTriggered = true;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (userInitiated) {
|
|
154
|
+
self.trigger('add', self, item.editor);
|
|
155
|
+
self.trigger('change', self);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
//Check if we need to wait for the item to complete before adding to the list
|
|
160
|
+
if (this.Editor.isAsync) {
|
|
161
|
+
item.editor.on('readyToAdd', _addItem, this);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
//Most editors can be added automatically
|
|
165
|
+
else {
|
|
166
|
+
_addItem();
|
|
167
|
+
item.editor.focus();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return item;
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Remove an item from the list
|
|
175
|
+
* @param {List.Item} item
|
|
176
|
+
*/
|
|
177
|
+
removeItem: function(item) {
|
|
178
|
+
//Confirm delete
|
|
179
|
+
var confirmMsg = this.schema.confirmDelete;
|
|
180
|
+
if (confirmMsg && !confirm(confirmMsg)) return;
|
|
181
|
+
|
|
182
|
+
var index = _.indexOf(this.items, item);
|
|
183
|
+
|
|
184
|
+
this.items[index].remove();
|
|
185
|
+
this.items.splice(index, 1);
|
|
186
|
+
|
|
187
|
+
if (item.addEventTriggered) {
|
|
188
|
+
this.trigger('remove', this, item.editor);
|
|
189
|
+
this.trigger('change', this);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (!this.items.length && !this.Editor.isAsync) this.addItem();
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
getValue: function() {
|
|
196
|
+
var values = _.map(this.items, function(item) {
|
|
197
|
+
return item.getValue();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
//Filter empty items
|
|
201
|
+
return _.without(values, undefined, '');
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
setValue: function(value) {
|
|
205
|
+
this.value = value;
|
|
206
|
+
this.render();
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
focus: function() {
|
|
210
|
+
if (this.hasFocus) return;
|
|
211
|
+
|
|
212
|
+
if (this.items[0]) this.items[0].editor.focus();
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
blur: function() {
|
|
216
|
+
if (!this.hasFocus) return;
|
|
217
|
+
|
|
218
|
+
var focusedItem = _.find(this.items, function(item) { return item.editor.hasFocus; });
|
|
219
|
+
|
|
220
|
+
if (focusedItem) focusedItem.editor.blur();
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Override default remove function in order to remove item views
|
|
225
|
+
*/
|
|
226
|
+
remove: function() {
|
|
227
|
+
_.invoke(this.items, 'remove');
|
|
228
|
+
|
|
229
|
+
Form.editors.Base.prototype.remove.call(this);
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Run validation
|
|
234
|
+
*
|
|
235
|
+
* @return {Object|Null}
|
|
236
|
+
*/
|
|
237
|
+
validate: function() {
|
|
238
|
+
|
|
239
|
+
//Collect errors
|
|
240
|
+
var errors = _.map(this.items, function(item) {
|
|
241
|
+
return item.validate();
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
//Check if any item has errors
|
|
245
|
+
var hasErrors = _.compact(errors).length ? true : false;
|
|
246
|
+
if (!hasErrors) return null;
|
|
247
|
+
|
|
248
|
+
//If so create a shared error
|
|
249
|
+
var fieldError = {
|
|
250
|
+
type: 'list',
|
|
251
|
+
message: 'Some of the items in the list failed validation',
|
|
252
|
+
errors: errors
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
return fieldError;
|
|
256
|
+
}
|
|
257
|
+
}, {
|
|
258
|
+
|
|
259
|
+
//STATICS
|
|
260
|
+
template: _.template('\
|
|
261
|
+
<div>\
|
|
262
|
+
<div data-items></div>\
|
|
263
|
+
<button type="button" data-action="add"><%= addLabel %></button>\
|
|
264
|
+
</div>\
|
|
265
|
+
', null, Form.templateSettings)
|
|
266
|
+
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* A single item in the list
|
|
272
|
+
*
|
|
273
|
+
* @param {editors.List} options.list The List editor instance this item belongs to
|
|
274
|
+
* @param {Function} options.Editor Editor constructor function
|
|
275
|
+
* @param {String} options.key Model key
|
|
276
|
+
* @param {Mixed} options.value Value
|
|
277
|
+
* @param {Object} options.schema Field schema
|
|
278
|
+
*/
|
|
279
|
+
Form.editors.List.Item = Form.editors.Base.extend({
|
|
280
|
+
|
|
281
|
+
events: {
|
|
282
|
+
'click [data-action="remove"]': function(event) {
|
|
283
|
+
event.preventDefault();
|
|
284
|
+
this.list.removeItem(this);
|
|
285
|
+
},
|
|
286
|
+
'keydown input[type=text]': function(event) {
|
|
287
|
+
if(event.keyCode !== 13) return;
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
this.list.addItem();
|
|
290
|
+
this.list.$list.find("> li:last input").focus();
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
initialize: function(options) {
|
|
295
|
+
this.list = options.list;
|
|
296
|
+
this.schema = options.schema || this.list.schema;
|
|
297
|
+
this.value = options.value;
|
|
298
|
+
this.Editor = options.Editor || Form.editors.Text;
|
|
299
|
+
this.key = options.key;
|
|
300
|
+
this.template = options.template || this.schema.itemTemplate || this.constructor.template;
|
|
301
|
+
this.errorClassName = options.errorClassName || this.constructor.errorClassName;
|
|
302
|
+
this.form = options.form;
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
render: function() {
|
|
306
|
+
var $ = Backbone.$;
|
|
307
|
+
|
|
308
|
+
//Create editor
|
|
309
|
+
this.editor = new this.Editor({
|
|
310
|
+
key: this.key,
|
|
311
|
+
schema: this.schema,
|
|
312
|
+
value: this.value,
|
|
313
|
+
list: this.list,
|
|
314
|
+
item: this,
|
|
315
|
+
form: this.form
|
|
316
|
+
}).render();
|
|
317
|
+
|
|
318
|
+
//Create main element
|
|
319
|
+
var $el = $($.trim(this.template()));
|
|
320
|
+
|
|
321
|
+
$el.find('[data-editor]').append(this.editor.el);
|
|
322
|
+
|
|
323
|
+
//Replace the entire element so there isn't a wrapper tag
|
|
324
|
+
this.setElement($el);
|
|
325
|
+
|
|
326
|
+
return this;
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
getValue: function() {
|
|
330
|
+
return this.editor.getValue();
|
|
331
|
+
},
|
|
332
|
+
|
|
333
|
+
setValue: function(value) {
|
|
334
|
+
this.editor.setValue(value);
|
|
335
|
+
},
|
|
336
|
+
|
|
337
|
+
focus: function() {
|
|
338
|
+
this.editor.focus();
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
blur: function() {
|
|
342
|
+
this.editor.blur();
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
remove: function() {
|
|
346
|
+
this.editor.remove();
|
|
347
|
+
|
|
348
|
+
Backbone.View.prototype.remove.call(this);
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
validate: function() {
|
|
352
|
+
var value = this.getValue(),
|
|
353
|
+
formValues = this.list.form ? this.list.form.getValue() : {},
|
|
354
|
+
validators = this.schema.validators,
|
|
355
|
+
getValidator = this.getValidator;
|
|
356
|
+
|
|
357
|
+
if (this.editor.nestedForm && this.editor.nestedForm.validate) {
|
|
358
|
+
return this.editor.nestedForm.validate();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (!validators) return null;
|
|
362
|
+
|
|
363
|
+
//Run through validators until an error is found
|
|
364
|
+
var error = null;
|
|
365
|
+
_.every(validators, function(validator) {
|
|
366
|
+
error = getValidator(validator)(value, formValues);
|
|
367
|
+
|
|
368
|
+
return error ? false : true;
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
//Show/hide error
|
|
372
|
+
if (error){
|
|
373
|
+
this.setError(error);
|
|
374
|
+
} else {
|
|
375
|
+
this.clearError();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
//Return error to be aggregated by list
|
|
379
|
+
return error ? error : null;
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Show a validation error
|
|
384
|
+
*/
|
|
385
|
+
setError: function(err) {
|
|
386
|
+
this.$el.addClass(this.errorClassName);
|
|
387
|
+
this.$el.attr('title', err.message);
|
|
388
|
+
},
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Hide validation errors
|
|
392
|
+
*/
|
|
393
|
+
clearError: function() {
|
|
394
|
+
this.$el.removeClass(this.errorClassName);
|
|
395
|
+
this.$el.attr('title', null);
|
|
396
|
+
}
|
|
397
|
+
}, {
|
|
398
|
+
|
|
399
|
+
//STATICS
|
|
400
|
+
template: _.template('\
|
|
401
|
+
<div>\
|
|
402
|
+
<span data-editor></span>\
|
|
403
|
+
<button type="button" data-action="remove">×</button>\
|
|
404
|
+
</div>\
|
|
405
|
+
', null, Form.templateSettings),
|
|
406
|
+
|
|
407
|
+
errorClassName: 'error'
|
|
408
|
+
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Base modal object editor for use with the List editor; used by Object
|
|
414
|
+
* and NestedModal list types
|
|
415
|
+
*/
|
|
416
|
+
Form.editors.List.Modal = Form.editors.Base.extend({
|
|
417
|
+
|
|
418
|
+
events: {
|
|
419
|
+
'click': 'openEditor'
|
|
420
|
+
},
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* @param {Object} options
|
|
424
|
+
* @param {Form} options.form The main form
|
|
425
|
+
* @param {Function} [options.schema.itemToString] Function to transform the value for display in the list.
|
|
426
|
+
* @param {String} [options.schema.itemType] Editor type e.g. 'Text', 'Object'.
|
|
427
|
+
* @param {Object} [options.schema.subSchema] Schema for nested form,. Required when itemType is 'Object'
|
|
428
|
+
* @param {Function} [options.schema.model] Model constructor function. Required when itemType is 'NestedModel'
|
|
429
|
+
*/
|
|
430
|
+
initialize: function(options) {
|
|
431
|
+
options = options || {};
|
|
432
|
+
|
|
433
|
+
Form.editors.Base.prototype.initialize.call(this, options);
|
|
434
|
+
|
|
435
|
+
//Dependencies
|
|
436
|
+
if (!Form.editors.List.Modal.ModalAdapter) throw new Error('A ModalAdapter is required');
|
|
437
|
+
|
|
438
|
+
this.form = options.form;
|
|
439
|
+
if (!options.form) throw new Error('Missing required option: "form"');
|
|
440
|
+
|
|
441
|
+
//Template
|
|
442
|
+
this.template = options.template || this.constructor.template;
|
|
443
|
+
},
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Render the list item representation
|
|
447
|
+
*/
|
|
448
|
+
render: function() {
|
|
449
|
+
var self = this;
|
|
450
|
+
|
|
451
|
+
//New items in the list are only rendered when the editor has been OK'd
|
|
452
|
+
if (_.isEmpty(this.value)) {
|
|
453
|
+
this.openEditor();
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
//But items with values are added automatically
|
|
457
|
+
else {
|
|
458
|
+
this.renderSummary();
|
|
459
|
+
|
|
460
|
+
setTimeout(function() {
|
|
461
|
+
self.trigger('readyToAdd');
|
|
462
|
+
}, 0);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (this.hasFocus) this.trigger('blur', this);
|
|
466
|
+
|
|
467
|
+
return this;
|
|
468
|
+
},
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Renders the list item representation
|
|
472
|
+
*/
|
|
473
|
+
renderSummary: function() {
|
|
474
|
+
this.$el.html($.trim(this.template({
|
|
475
|
+
summary: this.getStringValue()
|
|
476
|
+
})));
|
|
477
|
+
},
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Function which returns a generic string representation of an object
|
|
481
|
+
*
|
|
482
|
+
* @param {Object} value
|
|
483
|
+
*
|
|
484
|
+
* @return {String}
|
|
485
|
+
*/
|
|
486
|
+
itemToString: function(value) {
|
|
487
|
+
var createTitle = function(key) {
|
|
488
|
+
var context = { key: key };
|
|
489
|
+
|
|
490
|
+
return Form.Field.prototype.createTitle.call(context);
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
value = value || {};
|
|
494
|
+
|
|
495
|
+
//Pretty print the object keys and values
|
|
496
|
+
var parts = [];
|
|
497
|
+
_.each(this.nestedSchema, function(schema, key) {
|
|
498
|
+
var desc = schema.title ? schema.title : createTitle(key),
|
|
499
|
+
val = value[key];
|
|
500
|
+
|
|
501
|
+
if (_.isUndefined(val) || _.isNull(val)) val = '';
|
|
502
|
+
|
|
503
|
+
parts.push(desc + ': ' + val);
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
return parts.join('<br />');
|
|
507
|
+
},
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Returns the string representation of the object value
|
|
511
|
+
*/
|
|
512
|
+
getStringValue: function() {
|
|
513
|
+
var schema = this.schema,
|
|
514
|
+
value = this.getValue();
|
|
515
|
+
|
|
516
|
+
if (_.isEmpty(value)) return '[Empty]';
|
|
517
|
+
|
|
518
|
+
//If there's a specified toString use that
|
|
519
|
+
if (schema.itemToString) return schema.itemToString(value);
|
|
520
|
+
|
|
521
|
+
//Otherwise use the generic method or custom overridden method
|
|
522
|
+
return this.itemToString(value);
|
|
523
|
+
},
|
|
524
|
+
|
|
525
|
+
openEditor: function() {
|
|
526
|
+
var self = this,
|
|
527
|
+
ModalForm = this.form.constructor;
|
|
528
|
+
|
|
529
|
+
var form = this.modalForm = new ModalForm({
|
|
530
|
+
schema: this.nestedSchema,
|
|
531
|
+
data: this.value
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
var modal = this.modal = new Form.editors.List.Modal.ModalAdapter({
|
|
535
|
+
content: form,
|
|
536
|
+
animate: true
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
modal.open();
|
|
540
|
+
|
|
541
|
+
this.trigger('open', this);
|
|
542
|
+
this.trigger('focus', this);
|
|
543
|
+
|
|
544
|
+
modal.on('cancel', this.onModalClosed, this);
|
|
545
|
+
|
|
546
|
+
modal.on('ok', _.bind(this.onModalSubmitted, this));
|
|
547
|
+
},
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Called when the user clicks 'OK'.
|
|
551
|
+
* Runs validation and tells the list when ready to add the item
|
|
552
|
+
*/
|
|
553
|
+
onModalSubmitted: function() {
|
|
554
|
+
var modal = this.modal,
|
|
555
|
+
form = this.modalForm,
|
|
556
|
+
isNew = !this.value;
|
|
557
|
+
|
|
558
|
+
//Stop if there are validation errors
|
|
559
|
+
var error = form.validate();
|
|
560
|
+
if (error) return modal.preventClose();
|
|
561
|
+
|
|
562
|
+
//Store form value
|
|
563
|
+
this.value = form.getValue();
|
|
564
|
+
|
|
565
|
+
//Render item
|
|
566
|
+
this.renderSummary();
|
|
567
|
+
|
|
568
|
+
if (isNew) this.trigger('readyToAdd');
|
|
569
|
+
|
|
570
|
+
this.trigger('change', this);
|
|
571
|
+
|
|
572
|
+
this.onModalClosed();
|
|
573
|
+
},
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Cleans up references, triggers events. To be called whenever the modal closes
|
|
577
|
+
*/
|
|
578
|
+
onModalClosed: function() {
|
|
579
|
+
this.modal = null;
|
|
580
|
+
this.modalForm = null;
|
|
581
|
+
|
|
582
|
+
this.trigger('close', this);
|
|
583
|
+
this.trigger('blur', this);
|
|
584
|
+
},
|
|
585
|
+
|
|
586
|
+
getValue: function() {
|
|
587
|
+
return this.value;
|
|
588
|
+
},
|
|
589
|
+
|
|
590
|
+
setValue: function(value) {
|
|
591
|
+
this.value = value;
|
|
592
|
+
},
|
|
593
|
+
|
|
594
|
+
focus: function() {
|
|
595
|
+
if (this.hasFocus) return;
|
|
596
|
+
|
|
597
|
+
this.openEditor();
|
|
598
|
+
},
|
|
599
|
+
|
|
600
|
+
blur: function() {
|
|
601
|
+
if (!this.hasFocus) return;
|
|
602
|
+
|
|
603
|
+
if (this.modal) {
|
|
604
|
+
this.modal.trigger('cancel');
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}, {
|
|
608
|
+
//STATICS
|
|
609
|
+
template: _.template('\
|
|
610
|
+
<div><%= summary %></div>\
|
|
611
|
+
', null, Form.templateSettings),
|
|
612
|
+
|
|
613
|
+
//The modal adapter that creates and manages the modal dialog.
|
|
614
|
+
//Defaults to BootstrapModal (http://github.com/powmedia/backbone.bootstrap-modal)
|
|
615
|
+
//Can be replaced with another adapter that implements the same interface.
|
|
616
|
+
ModalAdapter: Backbone.BootstrapModal,
|
|
617
|
+
|
|
618
|
+
//Make the wait list for the 'ready' event before adding the item to the list
|
|
619
|
+
isAsync: true
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
Form.editors.List.Object = Form.editors.List.Modal.extend({
|
|
624
|
+
initialize: function () {
|
|
625
|
+
Form.editors.List.Modal.prototype.initialize.apply(this, arguments);
|
|
626
|
+
|
|
627
|
+
var schema = this.schema;
|
|
628
|
+
|
|
629
|
+
if (!schema.subSchema) throw new Error('Missing required option "schema.subSchema"');
|
|
630
|
+
|
|
631
|
+
this.nestedSchema = schema.subSchema;
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
Form.editors.List.NestedModel = Form.editors.List.Modal.extend({
|
|
637
|
+
initialize: function() {
|
|
638
|
+
Form.editors.List.Modal.prototype.initialize.apply(this, arguments);
|
|
639
|
+
|
|
640
|
+
var schema = this.schema;
|
|
641
|
+
|
|
642
|
+
if (!schema.model) throw new Error('Missing required option "schema.model"');
|
|
643
|
+
|
|
644
|
+
var nestedSchema = schema.model.prototype.schema;
|
|
645
|
+
|
|
646
|
+
this.nestedSchema = (_.isFunction(nestedSchema)) ? nestedSchema() : nestedSchema;
|
|
647
|
+
},
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Returns the string representation of the object value
|
|
651
|
+
*/
|
|
652
|
+
getStringValue: function() {
|
|
653
|
+
var schema = this.schema,
|
|
654
|
+
value = this.getValue();
|
|
655
|
+
|
|
656
|
+
if (_.isEmpty(value)) return null;
|
|
657
|
+
|
|
658
|
+
//If there's a specified toString use that
|
|
659
|
+
if (schema.itemToString) return schema.itemToString(value);
|
|
660
|
+
|
|
661
|
+
//Otherwise use the model
|
|
662
|
+
return new (schema.model)(value).toString();
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
})(Backbone.Form);
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
});
|