lcms-engine 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +25 -0
- data/.eslintignore +2 -1
- data/.eslintrc +23 -73
- data/.nvmrc +1 -1
- data/.overcommit.yml +8 -2
- data/.prettierrc +7 -0
- data/.rubocop.yml +5 -2
- data/.ruby-version +1 -1
- data/.stylelintignore +9 -0
- data/.stylelintrc +8 -0
- data/CHANGELOG.md +36 -2
- data/Dockerfile +3 -3
- data/Gemfile.lock +344 -297
- data/README.md +20 -18
- data/app/assets/config/lcms_engine_manifest.js +4 -2
- data/app/assets/javascripts/lcms/engine/admin/{application.js → lcms_engine_application.js} +1 -3
- data/app/assets/javascripts/lcms/engine/initializers/foundation.js +1 -1
- data/app/assets/javascripts/lcms/engine/{application.js → lcms_engine_application.js} +0 -0
- data/app/assets/stylesheets/lcms/engine/admin/collections.scss +2 -1
- data/app/assets/stylesheets/lcms/engine/admin/components.scss +60 -19
- data/app/assets/stylesheets/lcms/engine/admin/curriculums.scss +12 -10
- data/app/assets/stylesheets/lcms/engine/admin/lessons.scss +21 -15
- data/app/assets/stylesheets/lcms/engine/admin/materials.scss +25 -17
- data/app/assets/stylesheets/lcms/engine/admin/resources.scss +8 -7
- data/app/assets/stylesheets/lcms/engine/admin/standards.scss +4 -1
- data/app/assets/stylesheets/lcms/engine/admin/users.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/base/_colors.scss +8 -10
- data/app/assets/stylesheets/lcms/engine/base/_ld-colors.scss +10 -10
- data/app/assets/stylesheets/lcms/engine/components/_assoc-picker.scss +4 -5
- data/app/assets/stylesheets/lcms/engine/components/lesson/_activity.scss +6 -2
- data/app/assets/stylesheets/lcms/engine/components/lesson/_callout.scss +19 -5
- data/app/assets/stylesheets/lcms/engine/components/lesson/_columns.scss +4 -3
- data/app/assets/stylesheets/lcms/engine/components/lesson/_curriculum-map.scss +16 -7
- data/app/assets/stylesheets/lcms/engine/components/lesson/_def.scss +2 -2
- data/app/assets/stylesheets/lcms/engine/components/lesson/_expand.scss +9 -9
- data/app/assets/stylesheets/lcms/engine/components/lesson/_foundational-divider.scss +0 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_group.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_icons.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_image-wrap.scss +2 -2
- data/app/assets/stylesheets/lcms/engine/components/lesson/_inset.scss +7 -2
- data/app/assets/stylesheets/lcms/engine/components/lesson/_materials.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_multiple-choice.scss +4 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_override.scss +28 -9
- data/app/assets/stylesheets/lcms/engine/components/lesson/_pd.scss +7 -7
- data/app/assets/stylesheets/lcms/engine/components/lesson/_pv.scss +5 -4
- data/app/assets/stylesheets/lcms/engine/components/lesson/_section.scss +10 -3
- data/app/assets/stylesheets/lcms/engine/components/lesson/_selection-control.scss +14 -8
- data/app/assets/stylesheets/lcms/engine/components/lesson/_sidebar.scss +25 -10
- data/app/assets/stylesheets/lcms/engine/components/lesson/_title.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/components/lesson/_unit-map.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/components/material/_material.scss +3 -3
- data/app/assets/stylesheets/lcms/engine/components/material/_overlay.scss +12 -4
- data/app/assets/stylesheets/lcms/engine/components/material/_preview.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/components/support/_survey.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/layout/_footer.scss +29 -11
- data/app/assets/stylesheets/lcms/engine/layout/_header.scss +5 -5
- data/app/assets/stylesheets/lcms/engine/layout/_navigation.scss +4 -6
- data/app/assets/stylesheets/lcms/engine/layout/_page.scss +2 -2
- data/app/assets/stylesheets/lcms/engine/{admin.scss → lcms_engine_admin.scss} +26 -15
- data/app/assets/stylesheets/lcms/engine/lcms_engine_application.scss +9 -0
- data/app/assets/stylesheets/lcms/engine/pdf.scss +5 -26
- data/app/assets/stylesheets/lcms/engine/pdf_plain.scss +5 -23
- data/app/assets/stylesheets/lcms/engine/print/_base.scss +41 -12
- data/app/assets/stylesheets/lcms/engine/print/_cover.scss +12 -12
- data/app/assets/stylesheets/lcms/engine/print/_footer.scss +8 -3
- data/app/assets/stylesheets/lcms/engine/print/_gdoc-base.scss +10 -37
- data/app/assets/stylesheets/lcms/engine/print/_helpers.scss +5 -2
- data/app/assets/stylesheets/lcms/engine/print/_lesson-base.scss +2 -14
- data/app/assets/stylesheets/lcms/engine/print/_material-base.scss +1 -3
- data/app/assets/stylesheets/lcms/engine/print/_print.scss +15 -8
- data/app/assets/stylesheets/lcms/engine/print/_toc.scss +24 -9
- data/app/assets/stylesheets/lcms/engine/print/gdoc/_base-typography.scss +24 -6
- data/app/assets/stylesheets/lcms/engine/print/gdoc/_base.scss +10 -3
- data/app/assets/stylesheets/lcms/engine/print/gdoc/_colors.scss +3 -3
- data/app/assets/stylesheets/lcms/engine/print/gdoc/_header.scss +2 -2
- data/app/assets/stylesheets/lcms/engine/print/gdoc/_helpers.scss +1 -0
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_activity.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_agenda.scss +8 -2
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_callout.scss +16 -6
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_def.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_dialogue.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_expand.scss +5 -2
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_image-wrap.scss +5 -3
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_image.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_optbreak.scss +1 -0
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_section.scss +4 -1
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_smp.scss +1 -0
- data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_tables.scss +11 -3
- data/app/assets/stylesheets/lcms/engine/print/gdoc/material/_header.scss +5 -2
- data/app/assets/stylesheets/lcms/engine/print/lesson/_base-typography.scss +33 -9
- data/app/assets/stylesheets/lcms/engine/print/lesson/_group.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/print/lesson/_image.scss +3 -1
- data/app/assets/stylesheets/lcms/engine/print/lesson/_materials.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/print/lesson/_pd.scss +8 -4
- data/app/assets/stylesheets/lcms/engine/print/lesson/_section.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/print/material/_header.scss +4 -1
- data/app/assets/stylesheets/lcms/engine/themes/_material.scss +11 -11
- data/app/assets/stylesheets/lcms/engine/utils/_colorcodes.scss +15 -5
- data/app/assets/stylesheets/lcms/engine/utils/_functions.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/utils/_helpers.scss +23 -11
- data/app/assets/stylesheets/lcms/engine/utils/_placeholders.scss +1 -1
- data/app/assets/stylesheets/lcms/engine/utils/_variables.scss +11 -11
- data/app/assets/stylesheets/lcms/engine/vendors/{mathjax.css → mathjax.scss} +0 -0
- data/app/assets/stylesheets/lcms/engine/vendors/react-tagsinput.css +48 -0
- data/app/controllers/concerns/lcms/engine/reimportable.rb +1 -1
- data/app/controllers/lcms/engine/admin/access_codes_controller.rb +8 -3
- data/app/controllers/lcms/engine/admin/admin_controller.rb +5 -39
- data/app/controllers/lcms/engine/admin/association_picker_controller.rb +4 -1
- data/app/controllers/lcms/engine/admin/batch_reimports_controller.rb +2 -2
- data/app/controllers/lcms/engine/admin/curriculums_controller.rb +21 -2
- data/app/controllers/lcms/engine/admin/documents_controller.rb +26 -14
- data/app/controllers/lcms/engine/admin/materials_controller.rb +23 -13
- data/app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb +2 -2
- data/app/controllers/lcms/engine/admin/resources_controller.rb +9 -7
- data/app/controllers/lcms/engine/admin/settings_controller.rb +1 -1
- data/app/controllers/lcms/engine/admin/standards_controller.rb +2 -2
- data/app/controllers/lcms/engine/admin/users_controller.rb +10 -7
- data/app/controllers/lcms/engine/application_controller.rb +1 -1
- data/app/controllers/lcms/engine/resources_controller.rb +5 -5
- data/app/controllers/lcms/engine/welcome_controller.rb +11 -0
- data/app/entities/lcms/engine/hierarchical_position.rb +1 -2
- data/app/entities/lcms/engine/media_embed.rb +1 -1
- data/app/entities/lcms/engine/pagination.rb +14 -10
- data/app/entities/lcms/engine/roman_numerals.rb +1 -1
- data/app/exceptions/lcms/engine/document_error.rb +8 -0
- data/app/exceptions/lcms/engine/material_error.rb +8 -0
- data/app/helpers/admin/components_helper.rb +1 -1
- data/app/helpers/lcms/engine/path_helper.rb +32 -0
- data/app/helpers/lcms/engine/resource_helper.rb +1 -1
- data/app/helpers/lcms/engine/view_helper.rb +0 -8
- data/app/interactors/lcms/engine/explore_curriculum_interactor.rb +1 -1
- data/app/javascript/components/admin/ImportStatus.jsx +88 -58
- data/app/javascript/components/admin/Initializer.jsx +33 -35
- data/app/javascript/components/admin/MultiSelectedOperation.jsx +43 -19
- data/app/javascript/components/admin/association-picker/AssociationPicker.jsx +68 -48
- data/app/javascript/components/admin/association-picker/AssociationPickerItem.jsx +18 -7
- data/app/javascript/components/admin/association-picker/AssociationPickerResults.jsx +42 -18
- data/app/javascript/components/admin/association-picker/AssociationPickerWindow.jsx +47 -28
- data/app/javascript/components/admin/curriculum/CurriculumEditor.jsx +54 -33
- data/app/javascript/components/admin/curriculum/DirectoryPicker.jsx +80 -53
- data/app/javascript/components/admin/picker/PickerButton.jsx +16 -11
- data/app/javascript/components/admin/picker/pickerModal.jsx +6 -6
- data/app/javascript/components/admin/picker/pickerWindowWrapper.jsx +61 -40
- data/app/javascript/components/admin/resource-picker/ResourcePicker.jsx +54 -40
- data/app/javascript/components/admin/resource-picker/ResourcePickerResource.jsx +14 -3
- data/app/javascript/components/admin/resource-picker/ResourcePickerWindow.jsx +50 -21
- data/app/javascript/components/paginate/PageView.jsx +20 -8
- data/app/javascript/components/paginate/PaginationBoxView.jsx +78 -66
- data/app/javascript/components/paginate/PaginationListView.jsx +59 -45
- data/app/javascript/packs/lcms_engine_admin.js +15 -0
- data/app/javascript/packs/{application.js → lcms_engine_application.js} +5 -4
- data/app/javascript/packs/server_rendering.js +1 -0
- data/app/javascript/vendor/jstree/jstree.min.js +6 -0
- data/app/javascript/vendor/jstree/themes/default/32px.png +0 -0
- data/app/javascript/vendor/jstree/themes/default/40px.png +0 -0
- data/app/javascript/vendor/jstree/themes/default/style.css +1106 -0
- data/app/javascript/vendor/jstree/themes/default/style.min.css +1 -0
- data/app/javascript/vendor/jstree/themes/default/throbber.gif +0 -0
- data/app/javascript/vendor/jstree/themes/default-dark/32px.png +0 -0
- data/app/javascript/vendor/jstree/themes/default-dark/40px.png +0 -0
- data/app/javascript/vendor/jstree/themes/default-dark/style.css +1150 -0
- data/app/javascript/vendor/jstree/themes/default-dark/style.min.css +1 -0
- data/app/javascript/vendor/jstree/themes/default-dark/throbber.gif +0 -0
- data/app/jobs/lcms/engine/document_generate_job.rb +1 -1
- data/app/jobs/lcms/engine/document_generate_pdf_job.rb +5 -5
- data/app/jobs/lcms/engine/material_generate_pdf_job.rb +4 -4
- data/app/models/concerns/lcms/engine/navigable.rb +6 -10
- data/app/models/concerns/lcms/engine/searchable.rb +7 -0
- data/app/models/lcms/engine/document.rb +1 -1
- data/app/models/lcms/engine/resource.rb +1 -1
- data/app/models/lcms/engine/search/repository.rb +1 -1
- data/app/presenters/lcms/engine/content_presenter.rb +1 -1
- data/app/presenters/lcms/engine/curriculum_presenter.rb +21 -18
- data/app/presenters/lcms/engine/document_presenter.rb +3 -1
- data/app/presenters/lcms/engine/resource_presenter.rb +6 -3
- data/app/queries/lcms/engine/admin_documents_query.rb +1 -1
- data/app/queries/lcms/engine/admin_materials_query.rb +11 -2
- data/app/queries/lcms/engine/base_query.rb +1 -1
- data/app/services/lcms/engine/document_build_service.rb +2 -0
- data/app/services/lcms/engine/document_generator.rb +2 -2
- data/app/services/lcms/engine/google/drive_service.rb +7 -15
- data/app/services/lcms/engine/google/script_service.rb +7 -3
- data/app/services/lcms/engine/html_sanitizer.rb +1 -1
- data/app/services/lcms/engine/lti_exporter.rb +1 -1
- data/app/services/lcms/engine/material_preview_generator.rb +1 -1
- data/app/services/lcms/engine/s3_service.rb +14 -2
- data/app/tasks/resource_tasks.rb +2 -2
- data/app/views/layouts/lcms/engine/admin.html.erb +3 -3
- data/app/views/layouts/lcms/engine/application.html.erb +2 -2
- data/app/views/layouts/lcms/engine/lti.html.erb +1 -1
- data/app/views/lcms/engine/admin/access_codes/_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/access_codes/index.html.erb +3 -3
- data/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/curriculums/edit.html.erb +4 -2
- data/app/views/lcms/engine/admin/documents/_reimport.html.erb +1 -1
- data/app/views/lcms/engine/admin/documents/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/documents/import.html.erb +1 -1
- data/app/views/lcms/engine/admin/documents/index.html.erb +5 -3
- data/app/views/lcms/engine/admin/documents/new.html.erb +6 -2
- data/app/views/lcms/engine/admin/materials/_reimport.html.erb +1 -1
- data/app/views/lcms/engine/admin/materials/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/materials/import.html.erb +1 -1
- data/app/views/lcms/engine/admin/materials/index.html.erb +22 -18
- data/app/views/lcms/engine/admin/materials/new.html.erb +5 -1
- data/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb +1 -1
- data/app/views/lcms/engine/admin/resources/_fields.html.erb +4 -3
- data/app/views/lcms/engine/admin/resources/_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/resources/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/resources/index.html.erb +7 -5
- data/app/views/lcms/engine/admin/shared/_header.html.erb +12 -12
- data/app/views/lcms/engine/admin/standards/_form.html.erb +3 -1
- data/app/views/lcms/engine/admin/standards/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/users/_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/users/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/users/index.html.erb +6 -6
- data/app/views/lcms/engine/pages/not_found.html.erb +5 -0
- data/app/views/lcms/engine/resources/generic.html.erb +0 -4
- data/app/views/lcms/engine/resources/media.html.erb +0 -4
- data/app/views/lcms/engine/resources/show.html.erb +0 -2
- data/config/initializers/airbrake.rb +62 -10
- data/config/initializers/bitly.rb +1 -1
- data/config/initializers/carrier_wave.rb +6 -4
- data/config/initializers/ckeditor.rb +6 -0
- data/config/initializers/elasticsearch.rb +1 -1
- data/config/initializers/resque.rb +2 -2
- data/config/locales/admin/en.yml +0 -1
- data/config/locales/ui/en.yml +1 -0
- data/config/routes.rb +5 -2
- data/db/migrate/.keep +0 -0
- data/db/schema.rb +279 -311
- data/db/seeds.rb +0 -1
- data/docker-compose.ror4.yml +32 -0
- data/docker-compose.yml +6 -3
- data/docs/env-variables.md +40 -40
- data/docs/google-cloud-platform-setup.md +45 -17
- data/docs/how-to-build-and-publish.md +1 -0
- data/lcms-engine.gemspec +21 -15
- data/lib/doc_template/document.rb +3 -4
- data/lib/doc_template/document_toc.rb +2 -2
- data/lib/doc_template/objects/activity_metadata.rb +1 -1
- data/lib/doc_template/objects/toc_helpers.rb +4 -4
- data/lib/doc_template/objects/toc_metadata.rb +4 -6
- data/lib/doc_template/tags/answer_space_tag.rb +1 -1
- data/lib/doc_template/tags/base_tag.rb +2 -2
- data/lib/doc_template/tags/block_tag.rb +1 -1
- data/lib/doc_template/tags/table_tag.rb +1 -1
- data/lib/doc_template/template.rb +1 -1
- data/lib/doc_template.rb +9 -9
- data/lib/document_exporter/gdoc/base.rb +5 -2
- data/lib/document_exporter/pdf/base.rb +1 -1
- data/lib/document_exporter/pdf/document.rb +2 -2
- data/lib/document_exporter/pdf/material.rb +2 -2
- data/lib/document_exporter/pdf/student_material.rb +2 -2
- data/lib/document_exporter/pdf/teacher_material.rb +2 -2
- data/lib/document_renderer/part.rb +1 -3
- data/lib/lcms/engine/engine.rb +10 -9
- data/lib/lcms/engine/version.rb +1 -1
- data/lib/lcms/engine.rb +0 -1
- data/lib/lt/lcms/metadata/context.rb +56 -52
- data/lib/lt/lcms/metadata/service.rb +3 -2
- data/lib/tasks/cloud66.rake +2 -2
- data/lib/tasks/document.rake +4 -4
- data/lib/tasks/google.rake +29 -14
- data/lib/tasks/lcms/engine_tasks.rake +1 -1
- data/package.json +31 -10
- data/postcss.config.js +12 -0
- data/spec/controllers/admin/curriculums_controller_spec.rb +23 -0
- data/spec/controllers/admin/documents_controller_spec.rb +22 -2
- data/spec/controllers/admin/materials_controller_spec.rb +16 -3
- data/spec/controllers/admin/resource_bulk_edit_controller_spec.rb +1 -1
- data/spec/controllers/admin/resources_controller_spec.rb +1 -1
- data/spec/controllers/admin/settings_controller_spec.rb +1 -1
- data/spec/controllers/admin/standards_controller_spec.rb +1 -1
- data/spec/controllers/admin/welcome_controller_spec.rb +12 -10
- data/spec/controllers/resources_controller_spec.rb +3 -3
- data/spec/controllers/welcome_controller_spec.rb +38 -0
- data/spec/dummy/.traceroute.yaml +0 -2
- data/spec/dummy/bin/webpack +18 -0
- data/spec/dummy/bin/webpack-dev-server +18 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/assets.rb +6 -0
- data/spec/dummy/config/lcms-admin.yml +3 -7
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/db/schema.rb +5 -5
- data/spec/factories/documents.rb +1 -0
- data/spec/factories/downloads.rb +1 -1
- data/spec/factories/resources.rb +2 -2
- data/spec/features/admin/materials/add_material_spec.rb +2 -0
- data/spec/features/admin/users_spec.rb +2 -2
- data/spec/{controllers/admin/admin_controller_spec.rb → helpers/path_helper_spec.rb} +6 -6
- data/spec/lib/doc_template/objects/activity_metadata_spec.rb +1 -1
- data/spec/lib/doc_template/objects/agenda_metadata_spec.rb +2 -0
- data/spec/lib/doc_template/objects/toc_metadata_spec.rb +1 -1
- data/spec/lib/doc_template/tags/page_break_tag_spec.rb +1 -1
- data/spec/lib/doc_template/tags/pd_tag_spec.rb +1 -1
- data/spec/models/document_spec.rb +1 -1
- data/spec/models/standard_spec.rb +2 -0
- data/spec/queries/lcms/engine/admin_materials_query_spec.rb +34 -0
- data/spec/rails_helper.rb +6 -17
- data/spec/services/document_build_service_spec.rb +4 -11
- data/spec/services/s3_service_spec.rb +31 -0
- data/spec/support/concerns/navigable.rb +2 -0
- data/spec/support/routes.rb +4 -0
- data/spec/support/shared_examples/content_tag.rb +4 -4
- data/templates/routes.rb +0 -1
- data/yarn.lock +3412 -2933
- metadata +146 -288
- data/app/assets/stylesheets/lcms/engine/application.scss +0 -36
- data/app/assets/stylesheets/lcms/engine/vendors/jquery.tagsinput.css +0 -1
- data/app/exceptions/components_api_error.rb +0 -4
- data/app/exceptions/document_error.rb +0 -4
- data/app/exceptions/material_error.rb +0 -4
- data/app/javascript/packs/admin.js +0 -14
- data/app/models/lcms/engine/component.rb +0 -88
- data/app/presenters/lcms/engine/social_media_presenter.rb +0 -83
- data/app/views/lcms/engine/shared/_social_sharing.html.erb +0 -22
- data/db/migrate/20200217160930_change_document_parts_to_polymorphic.rb +0 -36
- data/db/migrate/20200218144849_drop_material_parts_table.rb +0 -7
- data/db/migrate/20200422130652_add_reimported_at_to_documents.rb +0 -7
- data/db/migrate/20200429130353_drop_pages.rb +0 -13
- data/db/seeds/pages.seeds.rb +0 -26
- data/lib/document_exporter.rb +0 -6
- data/lib/lcms/engine/migration.rb +0 -16
- data/spec/models/component_spec.rb +0 -60
- data/vendor/assets/javascripts/jquery.tagsinput.js +0 -1
@@ -1,36 +1,37 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import _ from 'lodash';
|
3
4
|
|
4
5
|
class ImportStatus extends React.Component {
|
5
6
|
constructor(props) {
|
6
|
-
super(props)
|
7
|
-
this.state = { jobs: props.jobs }
|
8
|
-
this.pollingInterval = 5000
|
9
|
-
this.chunkSize = 50
|
10
|
-
this.links = _.isEmpty(props.links) ? [`${props.type}/:id`] : props.links
|
7
|
+
super(props);
|
8
|
+
this.state = { jobs: props.jobs };
|
9
|
+
this.pollingInterval = 5000;
|
10
|
+
this.chunkSize = 50;
|
11
|
+
this.links = _.isEmpty(props.links) ? [`${props.type}/:id`] : props.links;
|
11
12
|
if (_.isEmpty(props.path)) {
|
12
|
-
const k = `lcms_engine_import_status_admin_${this.props.type}_path
|
13
|
-
this.path = Routes[k].call()
|
13
|
+
const k = `lcms_engine_import_status_admin_${this.props.type}_path`;
|
14
|
+
this.path = Routes[k].call();
|
14
15
|
} else {
|
15
|
-
this.path = props.path
|
16
|
+
this.path = props.path;
|
16
17
|
}
|
17
|
-
this.withPdf = props.with_pdf || false
|
18
|
+
this.withPdf = props.with_pdf || false;
|
18
19
|
}
|
19
20
|
|
20
21
|
componentDidMount() {
|
21
|
-
this.intervalFn = setInterval(this.poll.bind(this), this.pollingInterval)
|
22
|
+
this.intervalFn = setInterval(this.poll.bind(this), this.pollingInterval);
|
22
23
|
}
|
23
24
|
|
24
25
|
componentWillUnmount() {
|
25
|
-
clearInterval(this.intervalFn)
|
26
|
+
clearInterval(this.intervalFn);
|
26
27
|
}
|
27
28
|
|
28
29
|
poll() {
|
29
|
-
const pendingJobs = _.compact(_.map(this.state.jobs, (job, jid) => job.status !== 'done' ? jid : null))
|
30
|
+
const pendingJobs = _.compact(_.map(this.state.jobs, (job, jid) => (job.status !== 'done' ? jid : null)));
|
30
31
|
if (pendingJobs.length > 0) {
|
31
|
-
_.each(_.chunk(pendingJobs, this.chunkSize), jids => this.updateChunkStatus(jids))
|
32
|
+
_.each(_.chunk(pendingJobs, this.chunkSize), jids => this.updateChunkStatus(jids));
|
32
33
|
} else {
|
33
|
-
clearInterval(this.intervalFn)
|
34
|
+
clearInterval(this.intervalFn);
|
34
35
|
}
|
35
36
|
}
|
36
37
|
|
@@ -39,91 +40,120 @@ class ImportStatus extends React.Component {
|
|
39
40
|
jids: jids,
|
40
41
|
type: this.props.type,
|
41
42
|
_: Date.now(), // prevent cached response
|
42
|
-
}).done(res => {
|
43
|
-
let updatedJobs = {}
|
44
|
-
_.each(res, (val, jid) => {
|
45
|
-
updatedJobs[jid] = _.extend(this.state.jobs[jid], { status: val.status }, val.result)
|
46
|
-
})
|
47
|
-
this.setState({ jobs: _.extend(this.state.jobs, updatedJobs) })
|
48
|
-
}).fail(res => {
|
49
|
-
console.warn('check content export status', res)
|
50
43
|
})
|
44
|
+
.done(res => {
|
45
|
+
let updatedJobs = {};
|
46
|
+
_.each(res, (val, jid) => {
|
47
|
+
updatedJobs[jid] = _.extend(this.state.jobs[jid], { status: val.status }, val.result);
|
48
|
+
});
|
49
|
+
this.setState({ jobs: _.extend(this.state.jobs, updatedJobs) });
|
50
|
+
})
|
51
|
+
.fail(res => {
|
52
|
+
console.warn('check content export status', res); // eslint-disable-line no-console
|
53
|
+
});
|
51
54
|
}
|
52
55
|
|
53
56
|
resourceButton(job) {
|
54
57
|
if (this.withPdf) {
|
55
58
|
return (
|
56
|
-
<a
|
57
|
-
|
59
|
+
<a
|
60
|
+
href={job.link}
|
61
|
+
className="o-adm-materials__resource button primary u-margin-left--small u-margin-bottom--zero"
|
62
|
+
target="_blank"
|
63
|
+
rel="noreferrer"
|
64
|
+
>
|
58
65
|
<i className="far fa-file-pdf"></i>
|
59
66
|
</a>
|
60
|
-
)
|
67
|
+
);
|
61
68
|
}
|
62
69
|
|
63
|
-
let linkWithParams = function(route, params = {}) {
|
64
|
-
let path = route
|
70
|
+
let linkWithParams = function (route, params = {}) {
|
71
|
+
let path = route;
|
65
72
|
_.each(params, (v, k) => {
|
66
|
-
path = _.replace(path, `:${k}`, v)
|
67
|
-
})
|
68
|
-
return path
|
69
|
-
}
|
73
|
+
path = _.replace(path, `:${k}`, v);
|
74
|
+
});
|
75
|
+
return path;
|
76
|
+
};
|
70
77
|
|
71
78
|
return _.map(this.links, (link, idx) => (
|
72
|
-
<a
|
79
|
+
<a
|
80
|
+
key={`pl-${idx}`}
|
73
81
|
href={linkWithParams(link, { id: job.model.id })}
|
74
|
-
className="o-adm-materials__resource button primary u-margin-left--small u-margin-bottom--zero"
|
82
|
+
className="o-adm-materials__resource button primary u-margin-left--small u-margin-bottom--zero"
|
83
|
+
target="_blank"
|
84
|
+
rel="noreferrer"
|
85
|
+
>
|
75
86
|
<i className="fas fa-eye"></i>
|
76
87
|
</a>
|
77
|
-
))
|
88
|
+
));
|
78
89
|
}
|
79
90
|
|
80
91
|
spinner() {
|
81
|
-
return
|
92
|
+
return (
|
93
|
+
<span className="o-adm-materials__spinner button primary u-margin-bottom--zero">
|
94
|
+
<i className="fas fa-spin fa-spinner" />
|
95
|
+
</span>
|
96
|
+
);
|
82
97
|
}
|
83
98
|
|
84
99
|
render() {
|
85
|
-
const waitingCount = _.filter(this.state.jobs,
|
86
|
-
const importedCount = _.filter(this.state.jobs,
|
87
|
-
const failedCount = _.filter(this.state.jobs,
|
100
|
+
const waitingCount = _.filter(this.state.jobs, job => job.status !== 'done').length;
|
101
|
+
const importedCount = _.filter(this.state.jobs, job => job.status === 'done' && job.ok).length;
|
102
|
+
const failedCount = _.filter(this.state.jobs, job => job.status === 'done' && !job.ok).length;
|
88
103
|
|
89
104
|
const results = _.map(this.state.jobs, (job, key) => {
|
90
|
-
let status
|
105
|
+
let status;
|
91
106
|
if (job.status === 'done') {
|
92
|
-
status = job.ok ? 'ok' : 'err'
|
107
|
+
status = job.ok ? 'ok' : 'err';
|
93
108
|
} else {
|
94
|
-
status = job.status
|
109
|
+
status = job.status;
|
95
110
|
}
|
96
111
|
return (
|
97
112
|
<li className={`o-adm-materials__result o-adm-materials__result--${status}`} key={key}>
|
98
113
|
<div className="u-flex align-justify align-middle">
|
99
|
-
<a href={job.link} target=
|
114
|
+
<a href={job.link} target="_blank" className="o-adm-materials__link" rel="noreferrer">
|
100
115
|
{job.link}
|
101
116
|
</a>
|
102
117
|
{job.status !== 'done' ? this.spinner() : null}
|
103
118
|
{job.status === 'done' && job.ok ? <span>{this.resourceButton(job)}</span> : null}
|
104
119
|
</div>
|
105
|
-
{!
|
106
|
-
{!
|
120
|
+
{!_.isEmpty(job.errors) ? <p dangerouslySetInnerHTML={{ __html: _.join(job.errors, '<br/>') }}></p> : null}
|
121
|
+
{!_.isEmpty(job.warnings) ? (
|
122
|
+
<p
|
123
|
+
dangerouslySetInnerHTML={{
|
124
|
+
__html: _.join(job.warnings, '<br/>'),
|
125
|
+
}}
|
126
|
+
></p>
|
127
|
+
) : null}
|
107
128
|
</li>
|
108
|
-
)
|
109
|
-
})
|
129
|
+
);
|
130
|
+
});
|
110
131
|
|
111
132
|
return (
|
112
133
|
<div>
|
113
134
|
<p className="o-adm-materials__summary">
|
114
|
-
<span className=
|
115
|
-
<span className=
|
116
|
-
|
135
|
+
<span className="summary-entry">• {waitingCount} Files(s) Processing</span>
|
136
|
+
<span className="summary-entry">{`✓ ${importedCount} File(s) ${
|
137
|
+
this.withPdf ? 'Generated' : 'Imported'
|
138
|
+
}`}</span>
|
139
|
+
<span className="summary-entry">x {failedCount} File(s) Failed</span>
|
117
140
|
</p>
|
118
|
-
<aside className=
|
119
|
-
After the (re){`${this.withPdf ? 'generation' : 'import'}`} the files for export are still in process of being
|
141
|
+
<aside className="o-adm-materials__summary--aside u-margin-bottom--small">
|
142
|
+
After the (re){`${this.withPdf ? 'generation' : 'import'}`} the files for export are still in process of being
|
143
|
+
generated in the background. They will appear soon after.
|
120
144
|
</aside>
|
121
|
-
<ul className="o-adm-materials__results">
|
122
|
-
{results}
|
123
|
-
</ul>
|
145
|
+
<ul className="o-adm-materials__results">{results}</ul>
|
124
146
|
</div>
|
125
|
-
)
|
147
|
+
);
|
126
148
|
}
|
127
149
|
}
|
128
150
|
|
129
|
-
|
151
|
+
ImportStatus.propTypes = {
|
152
|
+
jobs: PropTypes.array,
|
153
|
+
links: PropTypes.array,
|
154
|
+
type: PropTypes.string,
|
155
|
+
path: PropTypes.string,
|
156
|
+
with_pdf: PropTypes.bool,
|
157
|
+
};
|
158
|
+
|
159
|
+
export default ImportStatus;
|
@@ -1,41 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
const Initializer = {
|
2
|
+
initializeResourcesForm: () => {
|
3
|
+
const form = $('form#resource_form');
|
4
|
+
if (!form.length) return;
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
}
|
6
|
+
const opr_desc = form.find('.resource_opr_description');
|
7
|
+
form.find('#resource_curriculum_type').change(ev => {
|
8
|
+
const el = $(ev.target);
|
9
|
+
if (el.val() === 'unit') {
|
10
|
+
opr_desc.slideDown();
|
11
|
+
} else {
|
12
|
+
opr_desc.slideUp();
|
13
|
+
}
|
14
|
+
});
|
15
|
+
},
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
initializeResourcesList: () => {
|
18
|
+
const page = $('.o-adm-list.o-adm-documents');
|
19
|
+
if (!page.length) return;
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
21
|
+
page.find('.c-reimport-with-materials__toggle input[type=checkbox]').change(() => {
|
22
|
+
const value = $(this).prop('checked') ? 1 : 0;
|
23
|
+
page.find('.c-reimport-doc-form .c-reimport-with-materials__field').val(value);
|
24
|
+
});
|
25
|
+
},
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
initializeSelectAll: () => {
|
28
|
+
const selector = $('.c-multi-selected--select-all');
|
29
|
+
if (!selector.length) return;
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
31
|
+
selector.find('input').change(ev => {
|
32
|
+
const el = $(ev.target);
|
33
|
+
const checked = el.prop('checked');
|
34
|
+
$('.table input[type=checkbox][name="selected_ids[]"]').prop('checked', checked);
|
35
|
+
});
|
36
|
+
},
|
37
|
+
};
|
36
38
|
|
37
|
-
export default
|
38
|
-
initializeResourcesList,
|
39
|
-
initializeResourcesForm,
|
40
|
-
initializeSelectAll,
|
41
|
-
}
|
39
|
+
export default Initializer;
|
@@ -1,40 +1,64 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import ReactDOM from 'react-dom'
|
3
|
-
import
|
1
|
+
import React from 'react';
|
2
|
+
import ReactDOM from 'react-dom';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import _ from 'lodash';
|
4
5
|
|
5
6
|
class MultiSelectedOperation extends React.Component {
|
7
|
+
constructor(props) {
|
8
|
+
super(props);
|
9
|
+
|
10
|
+
this.onSubmit = this.onSubmit.bind(this);
|
11
|
+
}
|
12
|
+
|
6
13
|
componentDidMount() {
|
7
|
-
|
8
|
-
$this
|
14
|
+
// eslint-disable-next-line react/no-find-dom-node
|
15
|
+
const $this = $(ReactDOM.findDOMNode(this));
|
16
|
+
$this.parent().addClass('c-multi-selected-btn');
|
9
17
|
}
|
10
18
|
|
11
19
|
onSubmit(evt) {
|
12
|
-
if (this.props.operation === 'delete' && !confirm('Are you sure?')) return
|
20
|
+
if (this.props.operation === 'delete' && !confirm('Are you sure?')) return; // eslint-disable-line no-restricted-globals
|
13
21
|
|
14
|
-
const entries = $('.o-page .table input[name="selected_ids[]"]')
|
15
|
-
const ids = _.filter(entries,
|
16
|
-
if (ids.length === 0) return evt.preventDefault()
|
22
|
+
const entries = $('.o-page .table input[name="selected_ids[]"]');
|
23
|
+
const ids = _.filter(entries, e => e.checked).map(e => e.value);
|
24
|
+
if (ids.length === 0) return evt.preventDefault();
|
17
25
|
|
18
|
-
const form = $(this.formRef)
|
19
|
-
form.find('input[name=selected_ids]').val(ids.join(','))
|
20
|
-
form.find('[type=submit]').prop('disabled', true)
|
26
|
+
const form = $(this.formRef);
|
27
|
+
form.find('input[name=selected_ids]').val(ids.join(','));
|
28
|
+
form.find('[type=submit]').prop('disabled', true);
|
21
29
|
}
|
22
30
|
|
23
31
|
render() {
|
24
|
-
const btnClass = `button ${this.props.btn_style}
|
25
|
-
const method =
|
26
|
-
const csrf_token = $('meta[name=csrf-token]').attr('content')
|
32
|
+
const btnClass = `button ${this.props.btn_style}`;
|
33
|
+
const method = this.props.operation === 'delete' ? 'delete' : 'post';
|
34
|
+
const csrf_token = $('meta[name=csrf-token]').attr('content');
|
27
35
|
return (
|
28
|
-
<form
|
36
|
+
<form
|
37
|
+
ref={ref => {
|
38
|
+
this.formRef = ref;
|
39
|
+
}}
|
40
|
+
action={this.props.path}
|
41
|
+
acceptCharset="UTF-8"
|
42
|
+
method="post"
|
43
|
+
className="c-reimport-doc-form"
|
44
|
+
onSubmit={this.onSubmit}
|
45
|
+
>
|
29
46
|
<input name="utf8" value="✓" type="hidden" />
|
30
47
|
<input name="_method" value={method} type="hidden" />
|
31
48
|
<input name="authenticity_token" value={csrf_token} type="hidden" />
|
32
49
|
<input name="selected_ids" type="hidden" />
|
33
|
-
<input name="with_materials" type="hidden" className="c-reimport-with-materials__field"/>
|
50
|
+
<input name="with_materials" type="hidden" className="c-reimport-with-materials__field" />
|
34
51
|
<input value={this.props.text} className={btnClass} type="submit" />
|
35
52
|
</form>
|
36
|
-
)
|
53
|
+
);
|
37
54
|
}
|
38
55
|
}
|
39
56
|
|
40
|
-
|
57
|
+
MultiSelectedOperation.propTypes = {
|
58
|
+
operation: PropTypes.string,
|
59
|
+
btn_style: PropTypes.string,
|
60
|
+
path: PropTypes.string,
|
61
|
+
text: PropTypes.string,
|
62
|
+
};
|
63
|
+
|
64
|
+
export default MultiSelectedOperation;
|
@@ -1,93 +1,103 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import ReactDOM from 'react-dom'
|
3
|
-
import
|
1
|
+
import React from 'react';
|
2
|
+
import ReactDOM from 'react-dom';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import _ from 'lodash';
|
4
5
|
// eslint-disable-next-line no-unused-vars
|
5
|
-
import AssociationPickerItem from './AssociationPickerItem'
|
6
|
-
import AssociationPickerWindow from './AssociationPickerWindow'
|
6
|
+
import AssociationPickerItem from './AssociationPickerItem';
|
7
|
+
import AssociationPickerWindow from './AssociationPickerWindow';
|
7
8
|
// eslint-disable-next-line no-unused-vars
|
8
|
-
import PickerButton from '../picker/PickerButton'
|
9
|
-
import pickerModal from '../picker/pickerModal'
|
10
|
-
import pickerWindowWrapper from '../picker/pickerWindowWrapper'
|
9
|
+
import PickerButton from '../picker/PickerButton';
|
10
|
+
import pickerModal from '../picker/pickerModal';
|
11
|
+
import pickerWindowWrapper from '../picker/pickerWindowWrapper';
|
12
|
+
import { Foundation } from 'foundation-sites';
|
13
|
+
import $ from 'jquery';
|
11
14
|
|
12
15
|
class AssociationPicker extends React.Component {
|
13
16
|
constructor(props) {
|
14
|
-
super(props)
|
17
|
+
super(props);
|
15
18
|
|
16
19
|
this.state = {
|
17
20
|
items: this.props.items || [],
|
18
|
-
}
|
21
|
+
};
|
19
22
|
}
|
20
23
|
|
21
24
|
get jqmodal() {
|
22
|
-
return $(this.modal)
|
25
|
+
return $(this.modal);
|
23
26
|
}
|
24
27
|
|
25
28
|
componentDidMount() {
|
29
|
+
Foundation.addToJquery($);
|
26
30
|
// eslint-disable-next-line no-undef
|
27
|
-
pickerModal.call(this)
|
31
|
+
pickerModal.call(this);
|
28
32
|
}
|
29
33
|
|
30
34
|
onClickSelect() {
|
31
35
|
// eslint-disable-next-line no-undef
|
32
|
-
const pickerComponent = pickerWindowWrapper(AssociationPickerWindow, 'lcms_engine_admin_association_picker_path')
|
33
|
-
const picker = React.createElement(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
const pickerComponent = pickerWindowWrapper(AssociationPickerWindow, 'lcms_engine_admin_association_picker_path');
|
37
|
+
const picker = React.createElement(
|
38
|
+
pickerComponent,
|
39
|
+
{
|
40
|
+
association: this.props.association,
|
41
|
+
allowCreate: this.props.allow_create,
|
42
|
+
allowMultiple: this.props.allow_multiple,
|
43
|
+
onClickDone: this.closeModal.bind(this),
|
44
|
+
onSelectItem: this.selectItem.bind(this),
|
45
|
+
selectedItems: this.state.items,
|
46
|
+
},
|
47
|
+
null
|
48
|
+
);
|
49
|
+
ReactDOM.render(picker, this.modal);
|
50
|
+
this.jqmodal.foundation('open');
|
43
51
|
}
|
44
52
|
|
45
53
|
selectItem(item, operation) {
|
46
54
|
if (!this.props.allow_multiple) {
|
47
|
-
this.closeModal()
|
55
|
+
this.closeModal();
|
48
56
|
}
|
49
|
-
operation === 'added' ? this.addItem(item) : this.removeItem(item)
|
57
|
+
operation === 'added' ? this.addItem(item) : this.removeItem(item);
|
50
58
|
}
|
51
59
|
|
52
60
|
closeModal() {
|
53
|
-
this.jqmodal.foundation('close')
|
61
|
+
this.jqmodal.foundation('close');
|
54
62
|
}
|
55
63
|
|
56
64
|
addItem(item) {
|
57
|
-
const newItems = this.props.allow_multiple ?
|
58
|
-
[...this.state.items, item] :
|
59
|
-
[item]
|
65
|
+
const newItems = this.props.allow_multiple ? [...this.state.items, item] : [item];
|
60
66
|
|
61
67
|
this.setState({
|
62
68
|
...this.state,
|
63
69
|
items: newItems,
|
64
|
-
})
|
70
|
+
});
|
65
71
|
}
|
66
72
|
|
67
73
|
removeItem(item) {
|
68
74
|
this.setState({
|
69
75
|
...this.state,
|
70
76
|
items: _.filter(this.state.items, r => r.id !== item.id),
|
71
|
-
})
|
77
|
+
});
|
72
78
|
}
|
73
79
|
|
74
80
|
render() {
|
75
|
-
const items = this.state.items.map(
|
76
|
-
return
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
const items = this.state.items.map(item => {
|
82
|
+
return (
|
83
|
+
<AssociationPickerItem
|
84
|
+
key={item.id}
|
85
|
+
name={this.props.name}
|
86
|
+
createName={this.props.create_name}
|
87
|
+
association={this.props.association}
|
88
|
+
allowMultiple={this.props.allow_multiple}
|
89
|
+
item={item}
|
90
|
+
// eslint-disable-next-line react/jsx-no-bind
|
91
|
+
onClickClose={() => this.removeItem(item)}
|
92
|
+
/>
|
93
|
+
);
|
94
|
+
});
|
87
95
|
|
88
|
-
const blankInput = this.props.allow_multiple ?
|
89
|
-
<input type="hidden" name={`${this.props.name}[]`} value="" />
|
96
|
+
const blankInput = this.props.allow_multiple ? (
|
97
|
+
<input type="hidden" name={`${this.props.name}[]`} value="" />
|
98
|
+
) : (
|
90
99
|
<span className="hide" />
|
100
|
+
);
|
91
101
|
|
92
102
|
return (
|
93
103
|
<PickerButton
|
@@ -96,10 +106,20 @@ class AssociationPicker extends React.Component {
|
|
96
106
|
// eslint-disable-next-line react/jsx-no-bind
|
97
107
|
onClick={this.onClickSelect.bind(this)}
|
98
108
|
// eslint-disable-next-line react/jsx-no-bind
|
99
|
-
onRef={m => this.modal = m}
|
109
|
+
onRef={m => (this.modal = m)}
|
100
110
|
/>
|
101
|
-
)
|
111
|
+
);
|
102
112
|
}
|
103
113
|
}
|
104
114
|
|
105
|
-
|
115
|
+
AssociationPicker.propTypes = {
|
116
|
+
item: PropTypes.object,
|
117
|
+
items: PropTypes.array,
|
118
|
+
association: PropTypes.string,
|
119
|
+
create_name: PropTypes.string,
|
120
|
+
allow_create: PropTypes.bool,
|
121
|
+
allow_multiple: PropTypes.bool,
|
122
|
+
name: PropTypes.string,
|
123
|
+
};
|
124
|
+
|
125
|
+
export default AssociationPicker;
|
@@ -1,15 +1,16 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
2
3
|
|
3
4
|
// eslint-disable-next-line no-unused-vars
|
4
5
|
function AssociationPickerItem(props) {
|
5
|
-
let input
|
6
|
+
let input;
|
6
7
|
|
7
8
|
if (props.item._create) {
|
8
|
-
input = <input type="hidden" name={`${props.createName}[]`} value={props.item.name}
|
9
|
+
input = <input type="hidden" name={`${props.createName}[]`} value={props.item.name} />;
|
9
10
|
} else if (props.allowMultiple) {
|
10
|
-
input = <input type="hidden" name={`${props.name}[]`} value={props.item.id}
|
11
|
+
input = <input type="hidden" name={`${props.name}[]`} value={props.item.id} />;
|
11
12
|
} else {
|
12
|
-
input = <input type="hidden" name={props.name} value={props.item.id}
|
13
|
+
input = <input type="hidden" name={props.name} value={props.item.id} />;
|
13
14
|
}
|
14
15
|
|
15
16
|
return (
|
@@ -17,10 +18,20 @@ function AssociationPickerItem(props) {
|
|
17
18
|
{input}
|
18
19
|
<div className="o-assocpicker-title">
|
19
20
|
{props.item.name}
|
20
|
-
<span className="o-assocpicker-close" onClick={props.onClickClose}
|
21
|
+
<span className="o-assocpicker-close" onClick={props.onClickClose}>
|
22
|
+
×
|
23
|
+
</span>
|
21
24
|
</div>
|
22
25
|
</div>
|
23
|
-
)
|
26
|
+
);
|
24
27
|
}
|
25
28
|
|
26
|
-
|
29
|
+
AssociationPickerItem.propTypes = {
|
30
|
+
item: PropTypes.object,
|
31
|
+
createName: PropTypes.string,
|
32
|
+
allowMultiple: PropTypes.bool,
|
33
|
+
name: PropTypes.string,
|
34
|
+
onClickClose: PropTypes.func,
|
35
|
+
};
|
36
|
+
|
37
|
+
export default AssociationPickerItem;
|