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,284 @@
|
|
|
1
|
+
define([
|
|
2
|
+
'core/origin',
|
|
3
|
+
'backboneForms',
|
|
4
|
+
], function(Origin, BackboneForms) {
|
|
5
|
+
var templates = Handlebars.templates;
|
|
6
|
+
var fieldTemplate = templates.field;
|
|
7
|
+
var templateData = Backbone.Form.Field.prototype.templateData;
|
|
8
|
+
var initialize = Backbone.Form.editors.Base.prototype.initialize;
|
|
9
|
+
var textInitialize = Backbone.Form.editors.Text.prototype.initialize;
|
|
10
|
+
var textAreaRender = Backbone.Form.editors.TextArea.prototype.render;
|
|
11
|
+
var textAreaSetValue = Backbone.Form.editors.TextArea.prototype.setValue;
|
|
12
|
+
|
|
13
|
+
Backbone.Form.prototype.constructor.template = templates.form;
|
|
14
|
+
Backbone.Form.Fieldset.prototype.template = templates.fieldset;
|
|
15
|
+
Backbone.Form.Field.prototype.template = fieldTemplate;
|
|
16
|
+
Backbone.Form.NestedField.prototype.template = fieldTemplate;
|
|
17
|
+
|
|
18
|
+
// add reset to default handler
|
|
19
|
+
Backbone.Form.Field.prototype.events = {
|
|
20
|
+
'click [data-action="default"]': function() {
|
|
21
|
+
this.setValue(this.editor.defaultValue);
|
|
22
|
+
this.editor.trigger('change', this);
|
|
23
|
+
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// merge schema into data
|
|
29
|
+
Backbone.Form.Field.prototype.templateData = function() {
|
|
30
|
+
return _.extend(templateData.call(this), this.schema, {
|
|
31
|
+
isDefaultValue: _.isEqual(this.editor.value, this.editor.defaultValue)
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// use default from schema and set up isDefaultValue toggler
|
|
36
|
+
Backbone.Form.editors.Base.prototype.initialize = function(options) {
|
|
37
|
+
var schemaDefault = options.schema.default;
|
|
38
|
+
|
|
39
|
+
if (schemaDefault !== undefined && options.id) {
|
|
40
|
+
this.defaultValue = schemaDefault;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.listenTo(this, 'change', function() {
|
|
44
|
+
if (this.hasNestedForm) return;
|
|
45
|
+
|
|
46
|
+
var isDefaultValue = _.isEqual(this.getValue(), this.defaultValue);
|
|
47
|
+
|
|
48
|
+
this.form.$('[data-editor-id="' + this.id + '"]')
|
|
49
|
+
.toggleClass('is-default-value', isDefaultValue);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
initialize.call(this, options);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// disable automatic completion on text fields if not specified
|
|
56
|
+
Backbone.Form.editors.Text.prototype.initialize = function(options) {
|
|
57
|
+
textInitialize.call(this, options);
|
|
58
|
+
|
|
59
|
+
if (!this.$el.attr('autocomplete')) {
|
|
60
|
+
this.$el.attr('autocomplete', 'off');
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// render ckeditor in textarea
|
|
65
|
+
Backbone.Form.editors.TextArea.prototype.render = function() {
|
|
66
|
+
textAreaRender.call(this);
|
|
67
|
+
function until(conditionFunction) {
|
|
68
|
+
function poll(resolve) {
|
|
69
|
+
if (conditionFunction()) {
|
|
70
|
+
resolve();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
setTimeout(function() {
|
|
74
|
+
poll(resolve)
|
|
75
|
+
}, 10);
|
|
76
|
+
}
|
|
77
|
+
return new Promise(poll);
|
|
78
|
+
}
|
|
79
|
+
function isAttached($element) {
|
|
80
|
+
return function() {
|
|
81
|
+
return Boolean($element.parents('body').length);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
until(isAttached(this.$el)).then(() => {
|
|
86
|
+
return CKEDITOR.create(this.$el[0], {
|
|
87
|
+
htmlSupport: {
|
|
88
|
+
allow: [
|
|
89
|
+
{
|
|
90
|
+
name: /.*/,
|
|
91
|
+
attributes: true,
|
|
92
|
+
classes: true,
|
|
93
|
+
styles: true
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
plugins: window.CKEDITOR.pluginsConfig.concat(function ItalicAsEmPlugin(editor) {
|
|
98
|
+
editor.conversion.attributeToElement({
|
|
99
|
+
model: 'italic',
|
|
100
|
+
view: 'em',
|
|
101
|
+
converterPriority: 'high'
|
|
102
|
+
});
|
|
103
|
+
}),
|
|
104
|
+
link: {
|
|
105
|
+
decorators: {
|
|
106
|
+
openInNewTab: {
|
|
107
|
+
mode: 'manual',
|
|
108
|
+
label: Origin.l10n.t('app.openintab'),
|
|
109
|
+
defaultValue: true,
|
|
110
|
+
attributes: {
|
|
111
|
+
target: '_blank',
|
|
112
|
+
rel: 'noopener noreferrer'
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
download: {
|
|
116
|
+
mode: 'manual',
|
|
117
|
+
label: Origin.l10n.t('app.forcedownload'),
|
|
118
|
+
attributes: {
|
|
119
|
+
download: 'download'
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
defaultProtocol: 'http://'
|
|
124
|
+
},
|
|
125
|
+
toolbar: {
|
|
126
|
+
items: [
|
|
127
|
+
'sourceEditing',
|
|
128
|
+
'showBlocks',
|
|
129
|
+
'undo',
|
|
130
|
+
'redo',
|
|
131
|
+
'|',
|
|
132
|
+
'findAndReplace',
|
|
133
|
+
'selectAll',
|
|
134
|
+
'|',
|
|
135
|
+
'numberedList',
|
|
136
|
+
'bulletedList',
|
|
137
|
+
'blockQuote',
|
|
138
|
+
'indent',
|
|
139
|
+
'outdent',
|
|
140
|
+
'|',
|
|
141
|
+
'bold',
|
|
142
|
+
'italic',
|
|
143
|
+
'underline',
|
|
144
|
+
'strikethrough',
|
|
145
|
+
'subscript',
|
|
146
|
+
'superscript',
|
|
147
|
+
'alignment',
|
|
148
|
+
'removeFormat',
|
|
149
|
+
'|',
|
|
150
|
+
'link',
|
|
151
|
+
'fontColor',
|
|
152
|
+
'fontBackgroundColor',
|
|
153
|
+
'|',
|
|
154
|
+
'specialCharacters',
|
|
155
|
+
'insertTable'
|
|
156
|
+
],
|
|
157
|
+
shouldNotGroupWhenFull: true
|
|
158
|
+
}
|
|
159
|
+
}).then(editor => {
|
|
160
|
+
this.editor = editor
|
|
161
|
+
CKEDITOR.instances = CKEDITOR.instances || []
|
|
162
|
+
CKEDITOR.instances.length = CKEDITOR.instances.length || 0;
|
|
163
|
+
this.editor.id = CKEDITOR.instances.length
|
|
164
|
+
CKEDITOR.instances.length++;
|
|
165
|
+
CKEDITOR.instances[this.editor.id] = this.editor
|
|
166
|
+
}).catch(e => console.error(e));
|
|
167
|
+
});
|
|
168
|
+
return this;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// get data from ckeditor in textarea
|
|
172
|
+
Backbone.Form.editors.TextArea.prototype.getValue = function() {
|
|
173
|
+
return this.editor.getData();
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// set value in ckeditor
|
|
177
|
+
Backbone.Form.editors.TextArea.prototype.setValue = function(value) {
|
|
178
|
+
textAreaSetValue.call(this, value);
|
|
179
|
+
|
|
180
|
+
if (this.editor) {
|
|
181
|
+
this.editor.setData(value);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// ckeditor removal
|
|
186
|
+
Backbone.Form.editors.TextArea.prototype.remove = async function() {
|
|
187
|
+
this.editor.stopListening()
|
|
188
|
+
delete CKEDITOR.instances[this.editor]
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// add override to allow prevention of validation
|
|
192
|
+
Backbone.Form.prototype.validate = function(options) {
|
|
193
|
+
var self = this;
|
|
194
|
+
var fields = this.fields;
|
|
195
|
+
var model = this.model;
|
|
196
|
+
var errors = {};
|
|
197
|
+
|
|
198
|
+
options = options || {};
|
|
199
|
+
|
|
200
|
+
//Collect errors from schema validation
|
|
201
|
+
// passing in validate: false will stop validation of the backbone forms validators
|
|
202
|
+
if (!options.skipModelValidate) {
|
|
203
|
+
_.each(fields, function(field) {
|
|
204
|
+
var error = field.validate();
|
|
205
|
+
if (!error) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
// add title to error if at field level
|
|
209
|
+
if (typeof error.type === 'string') {
|
|
210
|
+
error.title = field.schema.title;
|
|
211
|
+
}
|
|
212
|
+
errors[field.key] = error;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
//Get errors from default Backbone model validator
|
|
217
|
+
if (!options.skipModelValidate && model && model.validate) {
|
|
218
|
+
var modelErrors = model.validate(this.getValue());
|
|
219
|
+
|
|
220
|
+
if (modelErrors) {
|
|
221
|
+
var isDictionary = _.isObject(modelErrors) && !_.isArray(modelErrors);
|
|
222
|
+
|
|
223
|
+
//If errors are not in object form then just store on the error object
|
|
224
|
+
if (!isDictionary) {
|
|
225
|
+
errors._others = errors._others || [];
|
|
226
|
+
errors._others.push(modelErrors);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//Merge programmatic errors (requires model.validate() to return an object e.g. { fieldKey: 'error' })
|
|
230
|
+
if (isDictionary) {
|
|
231
|
+
_.each(modelErrors, function(val, key) {
|
|
232
|
+
//Set error on field if there isn't one already
|
|
233
|
+
if (fields[key] && !errors[key]) {
|
|
234
|
+
fields[key].setError(val);
|
|
235
|
+
errors[key] = val;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
else {
|
|
239
|
+
//Otherwise add to '_others' key
|
|
240
|
+
errors._others = errors._others || [];
|
|
241
|
+
var tmpErr = {};
|
|
242
|
+
tmpErr[key] = val;
|
|
243
|
+
errors._others.push(tmpErr);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return _.isEmpty(errors) ? null : errors;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// allow hyphen to be typed in number fields
|
|
254
|
+
Backbone.Form.editors.Number.prototype.onKeyPress = function(event) {
|
|
255
|
+
var self = this,
|
|
256
|
+
delayedDetermineChange = function() {
|
|
257
|
+
setTimeout(function() {
|
|
258
|
+
self.determineChange();
|
|
259
|
+
}, 0);
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
//Allow backspace
|
|
263
|
+
if (event.charCode === 0) {
|
|
264
|
+
delayedDetermineChange();
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
//Get the whole new value so that we can prevent things like double decimals points etc.
|
|
269
|
+
var newVal = this.$el.val()
|
|
270
|
+
if( event.charCode != undefined ) {
|
|
271
|
+
newVal = newVal + String.fromCharCode(event.charCode);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
var numeric = /^-?[0-9]*\.?[0-9]*?$/.test(newVal);
|
|
275
|
+
|
|
276
|
+
if (numeric) {
|
|
277
|
+
delayedDetermineChange();
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
event.preventDefault();
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
});
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
define([
|
|
2
|
+
'core/origin',
|
|
3
|
+
'core/helpers',
|
|
4
|
+
'backboneForms',
|
|
5
|
+
'backboneFormsLists',
|
|
6
|
+
'./backboneFormsOverrides',
|
|
7
|
+
'./views/scaffoldAssetItemView',
|
|
8
|
+
'./views/scaffoldAssetView',
|
|
9
|
+
'./views/scaffoldCodeEditorView',
|
|
10
|
+
'./views/scaffoldColourPickerView',
|
|
11
|
+
'./views/scaffoldDisplayTitleView',
|
|
12
|
+
'./views/scaffoldFileView',
|
|
13
|
+
'./views/scaffoldItemsModalView',
|
|
14
|
+
'./views/scaffoldListView',
|
|
15
|
+
'./views/scaffoldTagsView',
|
|
16
|
+
'./views/scaffoldUsersView'
|
|
17
|
+
], function(Origin, Helpers, BackboneForms, BackboneFormsLists, Overrides, ScaffoldAssetItemView, ScaffoldAssetView, ScaffoldCodeEditorView, ScaffoldColourPickerView, ScaffoldDisplayTitleView, ScaffoldFileView, ScaffoldItemsModalView, ScaffoldListView, ScaffoldTagsView, ScaffoldUsersView) {
|
|
18
|
+
|
|
19
|
+
var Scaffold = {};
|
|
20
|
+
var alternativeModel;
|
|
21
|
+
var alternativeAttribute;
|
|
22
|
+
var currentModel;
|
|
23
|
+
var currentForm;
|
|
24
|
+
var ActiveItemsModal = 0;
|
|
25
|
+
var isOverlayActive = false;
|
|
26
|
+
var defaultValidators = Object.keys(Backbone.Form.validators);
|
|
27
|
+
var customValidators = [];
|
|
28
|
+
var customTemplates = [];
|
|
29
|
+
|
|
30
|
+
Backbone.Form.editors.List.Modal.ModalAdapter = ScaffoldItemsModalView;
|
|
31
|
+
|
|
32
|
+
function generateFieldObject(field, key) {
|
|
33
|
+
var fieldType = field.type;
|
|
34
|
+
var isFieldTypeObject = fieldType === 'object';
|
|
35
|
+
var items = field.items;
|
|
36
|
+
var itemsProperties = items && items.properties;
|
|
37
|
+
var confirmDelete = Origin.l10n.t('app.confirmdelete');
|
|
38
|
+
var formsConfig = field._backboneForms || {};
|
|
39
|
+
|
|
40
|
+
var getType = function(item) {
|
|
41
|
+
if (!item) {
|
|
42
|
+
item = field;
|
|
43
|
+
}
|
|
44
|
+
var config = item._backboneForms;
|
|
45
|
+
var editor = typeof config === 'string' ? config : config && config.type;
|
|
46
|
+
|
|
47
|
+
if (editor) {
|
|
48
|
+
return editor;
|
|
49
|
+
}
|
|
50
|
+
switch (item.type) {
|
|
51
|
+
case 'array':
|
|
52
|
+
return 'List';
|
|
53
|
+
case 'boolean':
|
|
54
|
+
return 'Checkbox';
|
|
55
|
+
case 'number':
|
|
56
|
+
return 'Number';
|
|
57
|
+
case 'object':
|
|
58
|
+
return 'Object';
|
|
59
|
+
case 'string':
|
|
60
|
+
return 'Text';
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var getValidators = function() {
|
|
65
|
+
var validators = formsConfig.validators || [];
|
|
66
|
+
|
|
67
|
+
for (var i = 0, j = validators.length; i < j; i++) {
|
|
68
|
+
var validator = validators[i];
|
|
69
|
+
|
|
70
|
+
if (!validator) continue;
|
|
71
|
+
|
|
72
|
+
var isDefaultValidator = !Array.isArray(validator) && _.isObject(validator) ||
|
|
73
|
+
_.contains(defaultValidators, validator);
|
|
74
|
+
|
|
75
|
+
if (isDefaultValidator) continue;
|
|
76
|
+
|
|
77
|
+
var customValidator = _.findWhere(customValidators, { name: validator });
|
|
78
|
+
|
|
79
|
+
if (customValidator) {
|
|
80
|
+
validators[i] = customValidator.validatorMethod;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
validators[i] = '';
|
|
85
|
+
|
|
86
|
+
console.log('No validator of that sort – please register "' + validator +
|
|
87
|
+
'" by using Origin.scaffold.addCustomValidator("' + validator +
|
|
88
|
+
'", validatorMethod);');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return validators.filter(Boolean);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
var fieldObject = {
|
|
95
|
+
confirmDelete: itemsProperties ? confirmDelete : formsConfig.confirmDelete,
|
|
96
|
+
default: field.default,
|
|
97
|
+
editorAttrs: formsConfig.editorAttrs,
|
|
98
|
+
editorClass: formsConfig.editorClass,
|
|
99
|
+
fieldAttrs: formsConfig.fieldAttrs,
|
|
100
|
+
fieldClass: formsConfig.fieldClass,
|
|
101
|
+
help: field.description,
|
|
102
|
+
itemType: itemsProperties ? 'Object' : items && getType(items),
|
|
103
|
+
inputType: formsConfig.type ? formsConfig : getType(),
|
|
104
|
+
options: field.enum,
|
|
105
|
+
subSchema: isFieldTypeObject ? field.properties : itemsProperties || items,
|
|
106
|
+
title: field.title,
|
|
107
|
+
titleHTML: formsConfig.titleHTML,
|
|
108
|
+
type: getType(),
|
|
109
|
+
validators: getValidators()
|
|
110
|
+
};
|
|
111
|
+
return fieldObject;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function setUpSchemaFields(field, key, schema, scaffoldSchema) {
|
|
115
|
+
scaffoldSchema[key] = generateFieldObject(field, key);
|
|
116
|
+
|
|
117
|
+
var objectSchema = schema[key].properties || schema[key].subSchema;
|
|
118
|
+
var scaffoldObjectSchema = scaffoldSchema[key].subSchema;
|
|
119
|
+
|
|
120
|
+
for (var i in objectSchema) {
|
|
121
|
+
if (!objectSchema.hasOwnProperty(i)) continue;
|
|
122
|
+
|
|
123
|
+
var objectField = objectSchema[i];
|
|
124
|
+
|
|
125
|
+
setRequiredValidators(objectField.required, objectField.properties);
|
|
126
|
+
setUpSchemaFields(objectField, i, objectSchema, scaffoldObjectSchema);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The following attributes won't be rendered in the front-end forms
|
|
132
|
+
* @HACK @TODO this should be filtered with some useful logic
|
|
133
|
+
*/
|
|
134
|
+
var ATTRIBUTE_BLACKLIST = [
|
|
135
|
+
'_colorLabel',
|
|
136
|
+
'_component',
|
|
137
|
+
'_componentType',
|
|
138
|
+
'_courseId',
|
|
139
|
+
'_enabledPlugins',
|
|
140
|
+
'_hasPreview',
|
|
141
|
+
'_id',
|
|
142
|
+
'_isSelected',
|
|
143
|
+
'_latestTrackingId',
|
|
144
|
+
'_layout',
|
|
145
|
+
'_menu',
|
|
146
|
+
'_parentId',
|
|
147
|
+
'_sortOrder',
|
|
148
|
+
'_supportedLayout',
|
|
149
|
+
'_theme',
|
|
150
|
+
'_themePreset',
|
|
151
|
+
'_trackingId',
|
|
152
|
+
'_type',
|
|
153
|
+
'createdAt',
|
|
154
|
+
'createdBy',
|
|
155
|
+
'layoutOptions',
|
|
156
|
+
'menuSettings',
|
|
157
|
+
'themeSettings',
|
|
158
|
+
'themeVariables',
|
|
159
|
+
'updatedAt',
|
|
160
|
+
'userGroups',
|
|
161
|
+
];
|
|
162
|
+
function buildSchema(requiredKeys, properties) {
|
|
163
|
+
var scaffoldSchema = {};
|
|
164
|
+
|
|
165
|
+
const blacklist = [...ATTRIBUTE_BLACKLIST];
|
|
166
|
+
|
|
167
|
+
Object.entries(properties).forEach(([k,v]) => {
|
|
168
|
+
try {
|
|
169
|
+
if(v._backboneForms.showInUi === false && !blacklist.includes(k)) blacklist.push(k)
|
|
170
|
+
} catch(e) {}
|
|
171
|
+
});
|
|
172
|
+
properties = _.omit(properties, blacklist);
|
|
173
|
+
trimEmptyProperties(properties);
|
|
174
|
+
setRequiredValidators(_.without(requiredKeys, ...blacklist), properties);
|
|
175
|
+
properties = { type: 'object', properties };
|
|
176
|
+
setUpSchemaFields(properties, 'properties', { properties }, scaffoldSchema);
|
|
177
|
+
|
|
178
|
+
return scaffoldSchema.properties.subSchema;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function trimEmptyProperties(object) {
|
|
182
|
+
for (var key in object) {
|
|
183
|
+
if (!object.hasOwnProperty(key) || object[key].type !== 'object' || object[key]._backboneForms) continue;
|
|
184
|
+
if (_.isEmpty(object[key].properties)) delete object[key];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function buildFieldsets(schema, options) {
|
|
189
|
+
var fieldsets = {
|
|
190
|
+
general: { key: 'general', legend: Origin.l10n.t('app.scaffold.general'), fields: [] },
|
|
191
|
+
properties: { key: 'properties', legend: Origin.l10n.t('app.scaffold.properties'), fields: [] },
|
|
192
|
+
settings: { key: 'settings', legend: Origin.l10n.t('app.scaffold.settings'), fields: [] },
|
|
193
|
+
_extensions: { key: 'extensions', legend: Origin.l10n.t('app.scaffold.extensions'), fields: [ '_extensions' ] }
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
for (var key in schema) {
|
|
197
|
+
if (!schema.hasOwnProperty(key) || key === '_extensions') continue;
|
|
198
|
+
|
|
199
|
+
var value = schema[key];
|
|
200
|
+
var adaptConfig = value._adapt;
|
|
201
|
+
|
|
202
|
+
if (adaptConfig && adaptConfig.isSetting) {
|
|
203
|
+
fieldsets.settings.fields.push(key);
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (value.type !== 'object') {
|
|
207
|
+
fieldsets.general.fields.push(key);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (fieldsets[key]) {
|
|
211
|
+
fieldsets[key].fields.push(key);
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
fieldsets[key] = {
|
|
215
|
+
key: key,
|
|
216
|
+
legend: value.title,
|
|
217
|
+
description: value.description,
|
|
218
|
+
fields: [key]
|
|
219
|
+
};
|
|
220
|
+
// stop the titles displaying twice
|
|
221
|
+
var backboneSchema = options.model.schema[key];
|
|
222
|
+
if(backboneSchema) backboneSchema.title = backboneSchema.help = undefined;
|
|
223
|
+
}
|
|
224
|
+
// remove any empty fieldsets
|
|
225
|
+
Object.keys(fieldsets).forEach(k => {
|
|
226
|
+
const fields = fieldsets[k].fields;
|
|
227
|
+
if(!fields) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
/*
|
|
231
|
+
* Delete any 'empty' fieldsets:
|
|
232
|
+
* - No fields specified
|
|
233
|
+
* - Only an empty object with no sub-props exists on the schema, so there's nothing to render
|
|
234
|
+
* */
|
|
235
|
+
const noFieldsOnSchema = fields.some(f => {
|
|
236
|
+
return !schema[f] || (schema[f].type === 'object' && (schema[f].properties === undefined && !schema[f]._backboneForms));
|
|
237
|
+
});
|
|
238
|
+
if(!fields.length || noFieldsOnSchema) delete fieldsets[k];
|
|
239
|
+
});
|
|
240
|
+
return _.values(fieldsets);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function setRequiredValidators(requiredKeys, schema) {
|
|
244
|
+
if (!requiredKeys) return;
|
|
245
|
+
|
|
246
|
+
requiredKeys.forEach(function(requiredKey) {
|
|
247
|
+
var field = schema[requiredKey];
|
|
248
|
+
if(!field) {
|
|
249
|
+
throw new Error(`Required attribute '${requiredKey}' not present on schema, ${JSON.stringify(schema, null, 2)}`);
|
|
250
|
+
}
|
|
251
|
+
var config = field._backboneForms || {};
|
|
252
|
+
|
|
253
|
+
if (typeof config === 'string') {
|
|
254
|
+
field._backboneForms = { type: config, validators: [ 'required' ] };
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
(config.validators = config.validators || []).push('required');
|
|
258
|
+
field._backboneForms = config;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
Scaffold.buildFormInternal = async function(options) {
|
|
263
|
+
var model = options.model;
|
|
264
|
+
var schemaType = model.get('_type') || model._type || model.get('type') || model.type || options.schemaType;
|
|
265
|
+
|
|
266
|
+
if(schemaType === 'menu' || schemaType === 'page') {
|
|
267
|
+
schemaType = 'contentobject';
|
|
268
|
+
} else if(schemaType === 'component') {
|
|
269
|
+
try {
|
|
270
|
+
schemaType = `component&_component=${model.get('_component')}`;
|
|
271
|
+
} catch(e) {} // nothing to do
|
|
272
|
+
}
|
|
273
|
+
const query = model.get('_courseId') ? `&_courseId=${model.get('_courseId')}` : '';
|
|
274
|
+
const schema = await $.getJSON(`api/content/schema?_type=${schemaType}${query}`);
|
|
275
|
+
|
|
276
|
+
options.model.schema = buildSchema(schema.required, schema.properties);
|
|
277
|
+
options.fieldsets = buildFieldsets(schema.properties, options);
|
|
278
|
+
alternativeModel = options.alternativeModelToSave;
|
|
279
|
+
alternativeAttribute = options.alternativeAttributeToSave;
|
|
280
|
+
currentModel = options.model;
|
|
281
|
+
currentForm = new Backbone.Form(options).render();
|
|
282
|
+
return currentForm;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
Scaffold.buildForm = async function(options) {
|
|
286
|
+
try {
|
|
287
|
+
return await Scaffold.buildFormInternal(options);
|
|
288
|
+
} catch(e) {
|
|
289
|
+
console.trace(e);
|
|
290
|
+
throw new Error(Origin.l10n.t('app.formbuilderror'));
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
Scaffold.addCustomField = function(fieldName, view, overwrite) {
|
|
295
|
+
if (Backbone.Form.editors[fieldName] && !overwrite) {
|
|
296
|
+
console.log('Sorry, the custom field you’re trying to add already exists');
|
|
297
|
+
} else {
|
|
298
|
+
Backbone.Form.editors[fieldName] = view;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
Scaffold.addCustomTemplate = function(templateName, template, overwrite) {
|
|
303
|
+
if (!templateName || !template) {
|
|
304
|
+
return console.log('Custom templates need a name and template');
|
|
305
|
+
}
|
|
306
|
+
if (customTemplates[templateName] && !overwrite) {
|
|
307
|
+
console.log('Sorry, the custom template you’re trying to add already exists');
|
|
308
|
+
} else {
|
|
309
|
+
customTemplates[templateName] = template;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* @example
|
|
314
|
+
* Scaffold.addCustomValidator('title', function(value, formValues) {
|
|
315
|
+
* if(value.length > 11) return;
|
|
316
|
+
* return { type: 'password', message: 'Passwords must be at least 12 characters long' };
|
|
317
|
+
* });
|
|
318
|
+
*/
|
|
319
|
+
Scaffold.addCustomValidator = function(name, validatorMethod) {
|
|
320
|
+
if (!name || !validatorMethod) {
|
|
321
|
+
console.log('Custom validators need a name and validatorMethod');
|
|
322
|
+
} else {
|
|
323
|
+
customValidators.push({ name: name, validatorMethod: validatorMethod });
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
Scaffold.getCurrentModel = () => currentModel;
|
|
327
|
+
Scaffold.getCurrentForm = () => currentForm;
|
|
328
|
+
Scaffold.getAlternativeModel = () => alternativeModel;
|
|
329
|
+
Scaffold.getAlternativeAttribute = () => alternativeAttribute;
|
|
330
|
+
Scaffold.getCurrentActiveModals = () => ActiveItemsModal;
|
|
331
|
+
Scaffold.isOverlayActive = () => isOverlayActive;
|
|
332
|
+
Scaffold.setOverlayActive = value => isOverlayActive = value;
|
|
333
|
+
Scaffold.addCustomField('Boolean', Backbone.Form.editors.Checkbox);
|
|
334
|
+
Scaffold.addCustomField('QuestionButton', Backbone.Form.editors.Text);
|
|
335
|
+
|
|
336
|
+
Origin.on({
|
|
337
|
+
'scaffold:increaseActiveModals': () => ActiveItemsModal++,
|
|
338
|
+
'scaffold:decreaseActiveModals': () => ActiveItemsModal--
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
Origin.scaffold = Scaffold;
|
|
342
|
+
});
|