lcms-engine 0.3.1 → 0.4.1
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 +42 -2
- data/Dockerfile +3 -3
- data/Gemfile.lock +345 -298
- data/README.md +21 -33
- 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 +14 -0
- data/docs/pdf-generation.md +31 -0
- data/lcms-engine.gemspec +27 -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 +41 -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 +152 -289
- 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,75 +1,83 @@
|
|
1
1
|
// from https://github.com/AdeleD/react-paginate (converted)
|
2
2
|
|
3
|
-
import React from 'react'
|
4
|
-
import PropTypes from 'prop-types'
|
5
|
-
import PaginationListView from './PaginationListView'
|
6
|
-
import classNames from 'classnames'
|
3
|
+
import React from 'react';
|
4
|
+
import PropTypes from 'prop-types';
|
5
|
+
import PaginationListView from './PaginationListView';
|
6
|
+
import classNames from 'classnames';
|
7
7
|
|
8
8
|
class PaginationBoxView extends React.Component {
|
9
9
|
constructor(props) {
|
10
|
-
super(props)
|
10
|
+
super(props);
|
11
11
|
|
12
12
|
this.state = {
|
13
13
|
selected: props.initialSelected ? props.initialSelected : 0,
|
14
|
-
}
|
14
|
+
};
|
15
|
+
|
16
|
+
this.handlePageSelected = this.handlePageSelected.bind(this);
|
17
|
+
this.handlePreviousPage = this.handlePreviousPage.bind(this);
|
18
|
+
this.handleNextPage = this.handleNextPage.bind(this);
|
15
19
|
}
|
16
20
|
|
17
21
|
componentDidMount() {
|
18
22
|
// Call the callback with the initialSelected item:
|
19
|
-
if (typeof
|
23
|
+
if (typeof this.props.initialSelected !== 'undefined') {
|
20
24
|
//this.callCallback(this.props.initialSelected);
|
21
25
|
}
|
22
26
|
}
|
23
27
|
|
24
28
|
handlePreviousPage(evt) {
|
25
|
-
evt.preventDefault ? evt.preventDefault() : (evt.returnValue = false)
|
29
|
+
evt.preventDefault ? evt.preventDefault() : (evt.returnValue = false);
|
26
30
|
if (this.state.selected > 0) {
|
27
|
-
this.handlePageSelected(this.state.selected - 1, evt)
|
31
|
+
this.handlePageSelected(this.state.selected - 1, evt);
|
28
32
|
}
|
29
33
|
}
|
30
34
|
|
31
35
|
handleNextPage(evt) {
|
32
|
-
evt.preventDefault ? evt.preventDefault() : (evt.returnValue = false)
|
36
|
+
evt.preventDefault ? evt.preventDefault() : (evt.returnValue = false);
|
33
37
|
if (this.state.selected < this.props.pageNum - 1) {
|
34
|
-
this.handlePageSelected(this.state.selected + 1, evt)
|
38
|
+
this.handlePageSelected(this.state.selected + 1, evt);
|
35
39
|
}
|
36
40
|
}
|
37
41
|
|
38
42
|
handlePageSelected(selected, evt) {
|
39
|
-
evt.preventDefault ? evt.preventDefault() : (evt.returnValue = false)
|
43
|
+
evt.preventDefault ? evt.preventDefault() : (evt.returnValue = false);
|
40
44
|
|
41
|
-
if (this.state.selected === selected) return
|
45
|
+
if (this.state.selected === selected) return;
|
42
46
|
|
43
|
-
this.setState({ selected: selected })
|
47
|
+
this.setState({ selected: selected });
|
44
48
|
|
45
49
|
// Call the callback with the new selected item:
|
46
|
-
this.callCallback(selected)
|
50
|
+
this.callCallback(selected);
|
47
51
|
}
|
48
52
|
|
49
53
|
callCallback(selectedItem) {
|
50
|
-
if (typeof
|
51
|
-
|
52
|
-
this.props.clickCallback({ selected: selectedItem })
|
54
|
+
if (typeof this.props.clickCallback !== 'undefined' && typeof this.props.clickCallback === 'function') {
|
55
|
+
this.props.clickCallback({ selected: selectedItem });
|
53
56
|
}
|
54
57
|
}
|
55
58
|
|
56
59
|
render() {
|
57
|
-
const previousClasses = classNames(this.props.itemClassName, this.props.previousClassName,
|
58
|
-
|
60
|
+
const previousClasses = classNames(this.props.itemClassName, this.props.previousClassName, {
|
61
|
+
[`${this.props.itemClassName}--disabled`]: this.state.selected === 0,
|
62
|
+
});
|
59
63
|
|
60
|
-
const nextClasses = classNames(this.props.itemClassName, this.props.nextClassName,
|
61
|
-
|
64
|
+
const nextClasses = classNames(this.props.itemClassName, this.props.nextClassName, {
|
65
|
+
[`${this.props.itemClassName}--disabled`]: this.state.selected === this.props.pageNum - 1,
|
66
|
+
});
|
62
67
|
|
68
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
63
69
|
return (
|
64
70
|
<ul className={this.props.containerClassName}>
|
65
|
-
<li onClick={this.handlePreviousPage
|
66
|
-
<a href="" className={this.props.previousLinkClassName}>
|
71
|
+
<li onClick={this.handlePreviousPage} className={previousClasses}>
|
72
|
+
<a href="" className={this.props.previousLinkClassName}>
|
73
|
+
{this.props.previousLabel}
|
74
|
+
</a>
|
67
75
|
</li>
|
68
76
|
|
69
77
|
<li className={classNames(this.props.itemClassName, this.props.pagesClassName)}>
|
70
78
|
<PaginationListView
|
71
79
|
// eslint-disable-next-line react/jsx-no-bind
|
72
|
-
onPageSelected={this.handlePageSelected
|
80
|
+
onPageSelected={this.handlePageSelected}
|
73
81
|
selected={this.state.selected}
|
74
82
|
pageNum={this.props.pageNum}
|
75
83
|
pageRangeDisplayed={this.props.pageRangeDisplayed}
|
@@ -79,58 +87,62 @@ class PaginationBoxView extends React.Component {
|
|
79
87
|
pageClassName={this.props.pageClassName}
|
80
88
|
pageLinkClassName={this.props.pageLinkClassName}
|
81
89
|
activeClassName={this.props.activeClassName}
|
82
|
-
disabledClassName={this.props.disabledClassName}
|
90
|
+
disabledClassName={this.props.disabledClassName}
|
91
|
+
/>
|
83
92
|
</li>
|
84
93
|
|
85
|
-
<li onClick={this.handleNextPage
|
86
|
-
<a href="" className={this.props.nextLinkClassName}>
|
94
|
+
<li onClick={this.handleNextPage} className={nextClasses}>
|
95
|
+
<a href="" className={this.props.nextLinkClassName}>
|
96
|
+
{this.props.nextLabel}
|
97
|
+
</a>
|
87
98
|
</li>
|
88
99
|
</ul>
|
89
|
-
)
|
100
|
+
);
|
101
|
+
/* eslint-enable jsx-a11y/anchor-is-valid */
|
90
102
|
}
|
91
103
|
|
92
|
-
|
104
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
93
105
|
if (typeof nextProps.forceSelected !== 'undefined' && nextProps.forceSelected !== this.state.selected) {
|
94
|
-
this.setState({ selected: nextProps.forceSelected })
|
106
|
+
this.setState({ selected: nextProps.forceSelected });
|
95
107
|
}
|
96
108
|
}
|
97
109
|
}
|
98
110
|
|
99
111
|
PaginationBoxView.propTypes = {
|
100
|
-
pageNum
|
101
|
-
pageRangeDisplayed
|
102
|
-
marginPagesDisplayed
|
103
|
-
previousLabel
|
104
|
-
nextLabel
|
105
|
-
breakLabel
|
106
|
-
clickCallback
|
107
|
-
initialSelected
|
108
|
-
forceSelected
|
109
|
-
containerClassName
|
110
|
-
subContainerClassName
|
111
|
-
pagesClassName
|
112
|
-
pageClassName
|
113
|
-
pageLinkClassName
|
114
|
-
activeClassName
|
115
|
-
previousClassName
|
116
|
-
nextClassName
|
117
|
-
itemClassName
|
118
|
-
previousLinkClassName
|
119
|
-
nextLinkClassName
|
120
|
-
disabledClassName
|
121
|
-
}
|
112
|
+
pageNum: PropTypes.number.isRequired,
|
113
|
+
pageRangeDisplayed: PropTypes.number.isRequired,
|
114
|
+
marginPagesDisplayed: PropTypes.number.isRequired,
|
115
|
+
previousLabel: PropTypes.node,
|
116
|
+
nextLabel: PropTypes.node,
|
117
|
+
breakLabel: PropTypes.node,
|
118
|
+
clickCallback: PropTypes.func,
|
119
|
+
initialSelected: PropTypes.number,
|
120
|
+
forceSelected: PropTypes.number,
|
121
|
+
containerClassName: PropTypes.string,
|
122
|
+
subContainerClassName: PropTypes.string,
|
123
|
+
pagesClassName: PropTypes.string,
|
124
|
+
pageClassName: PropTypes.string,
|
125
|
+
pageLinkClassName: PropTypes.string,
|
126
|
+
activeClassName: PropTypes.string,
|
127
|
+
previousClassName: PropTypes.string,
|
128
|
+
nextClassName: PropTypes.string,
|
129
|
+
itemClassName: PropTypes.string,
|
130
|
+
previousLinkClassName: PropTypes.string,
|
131
|
+
nextLinkClassName: PropTypes.string,
|
132
|
+
disabledClassName: PropTypes.string,
|
133
|
+
};
|
122
134
|
|
123
135
|
PaginationBoxView.defaultProps = {
|
124
|
-
pageNum
|
125
|
-
pageRangeDisplayed
|
126
|
-
marginPagesDisplayed
|
127
|
-
activeClassName
|
128
|
-
previousClassName
|
129
|
-
nextClassName
|
130
|
-
previousLabel
|
131
|
-
nextLabel
|
132
|
-
breakLabel
|
133
|
-
disabledClassName
|
134
|
-
}
|
135
|
-
|
136
|
-
export default PaginationBoxView
|
136
|
+
pageNum: 10,
|
137
|
+
pageRangeDisplayed: 2,
|
138
|
+
marginPagesDisplayed: 3,
|
139
|
+
activeClassName: 'selected',
|
140
|
+
previousClassName: 'previous',
|
141
|
+
nextClassName: 'next',
|
142
|
+
previousLabel: 'Previous',
|
143
|
+
nextLabel: 'Next',
|
144
|
+
breakLabel: '...',
|
145
|
+
disabledClassName: 'disabled',
|
146
|
+
};
|
147
|
+
|
148
|
+
export default PaginationBoxView;
|
@@ -1,96 +1,110 @@
|
|
1
1
|
// from https://github.com/AdeleD/react-paginate (converted)
|
2
2
|
|
3
|
-
import React from 'react'
|
4
|
-
import PageView from './PageView'
|
3
|
+
import React from 'react';
|
4
|
+
import PageView from './PageView';
|
5
|
+
import PropTypes from 'prop-types';
|
5
6
|
|
6
7
|
class PaginationListView extends React.Component {
|
7
8
|
lessPageRangeItems() {
|
8
|
-
let result = {}
|
9
|
+
let result = {};
|
9
10
|
for (let index = 0; index < this.props.pageNum; index++) {
|
10
|
-
result['key' + index] = this.pageViewElement(index)
|
11
|
+
result['key' + index] = this.pageViewElement(index);
|
11
12
|
}
|
12
|
-
return result
|
13
|
+
return result;
|
13
14
|
}
|
14
15
|
|
15
16
|
pageViewElement(index) {
|
16
|
-
return (
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
return (
|
18
|
+
<PageView
|
19
|
+
// eslint-disable-next-line react/jsx-no-bind
|
20
|
+
onClick={this.props.onPageSelected.bind(null, index)}
|
21
|
+
selected={this.props.selected === index}
|
22
|
+
pageClassName={this.props.pageClassName}
|
23
|
+
pageLinkClassName={this.props.pageLinkClassName}
|
24
|
+
activeClassName={this.props.activeClassName}
|
25
|
+
page={index + 1}
|
26
|
+
/>
|
27
|
+
);
|
24
28
|
}
|
25
29
|
|
26
30
|
render() {
|
27
|
-
let items = {}
|
31
|
+
let items = {};
|
28
32
|
|
29
33
|
if (this.props.pageNum <= this.props.pageRangeDisplayed) {
|
30
|
-
items = this.lessPageRangeItems()
|
34
|
+
items = this.lessPageRangeItems();
|
31
35
|
} else {
|
32
|
-
let leftSide
|
33
|
-
let rightSide =
|
36
|
+
let leftSide = this.props.pageRangeDisplayed / 2;
|
37
|
+
let rightSide = this.props.pageRangeDisplayed - leftSide;
|
34
38
|
|
35
39
|
if (this.props.selected > this.props.pageNum - this.props.pageRangeDisplayed / 2) {
|
36
|
-
rightSide = this.props.pageNum - this.props.selected
|
37
|
-
leftSide
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
|
-
rightSide = this.props.pageRangeDisplayed - leftSide
|
40
|
+
rightSide = this.props.pageNum - this.props.selected;
|
41
|
+
leftSide = this.props.pageRangeDisplayed - rightSide;
|
42
|
+
} else if (this.props.selected < this.props.pageRangeDisplayed / 2) {
|
43
|
+
leftSide = this.props.selected;
|
44
|
+
rightSide = this.props.pageRangeDisplayed - leftSide;
|
42
45
|
}
|
43
46
|
|
44
|
-
let index
|
45
|
-
let page
|
47
|
+
let index;
|
48
|
+
let page;
|
46
49
|
|
47
50
|
for (index = 0; index < this.props.pageNum; index++) {
|
48
|
-
page = index + 1
|
49
|
-
const pageView = this.pageViewElement(index)
|
51
|
+
page = index + 1;
|
52
|
+
const pageView = this.pageViewElement(index);
|
50
53
|
|
51
54
|
if (page <= this.props.marginPagesDisplayed) {
|
52
|
-
items['key' + index] = pageView
|
53
|
-
continue
|
55
|
+
items['key' + index] = pageView;
|
56
|
+
continue;
|
54
57
|
}
|
55
58
|
|
56
59
|
if (page > this.props.pageNum - this.props.marginPagesDisplayed) {
|
57
|
-
items['key' + index] = pageView
|
58
|
-
continue
|
60
|
+
items['key' + index] = pageView;
|
61
|
+
continue;
|
59
62
|
}
|
60
63
|
|
61
|
-
if (
|
62
|
-
items['key' + index] = pageView
|
63
|
-
continue
|
64
|
+
if (index >= this.props.selected - leftSide && index <= this.props.selected + rightSide) {
|
65
|
+
items['key' + index] = pageView;
|
66
|
+
continue;
|
64
67
|
}
|
65
68
|
|
66
|
-
let keys
|
67
|
-
let breakLabelKey
|
68
|
-
let breakLabelValue = items[breakLabelKey]
|
69
|
+
let keys = Object.keys(items);
|
70
|
+
let breakLabelKey = keys[keys.length - 1];
|
71
|
+
let breakLabelValue = items[breakLabelKey];
|
69
72
|
|
70
73
|
if (breakLabelValue !== this.props.breakLabel) {
|
71
|
-
items['key' + index] = this.props.breakLabel
|
74
|
+
items['key' + index] = this.props.breakLabel;
|
72
75
|
}
|
73
76
|
}
|
74
77
|
}
|
75
78
|
|
76
|
-
let itemsToRender = []
|
79
|
+
let itemsToRender = [];
|
77
80
|
for (let key in Object.keys(items)) {
|
78
81
|
itemsToRender.push({
|
79
82
|
key: key,
|
80
83
|
value: items[key],
|
81
|
-
})
|
84
|
+
});
|
82
85
|
}
|
83
86
|
|
84
87
|
return (
|
85
88
|
<ul className={this.props.subContainerClassName}>
|
86
89
|
{itemsToRender.map(item => (
|
87
|
-
<React.Fragment key={item.key}>
|
88
|
-
{item.value}
|
89
|
-
</React.Fragment>
|
90
|
+
<React.Fragment key={item.key}>{item.value}</React.Fragment>
|
90
91
|
))}
|
91
92
|
</ul>
|
92
|
-
)
|
93
|
+
);
|
93
94
|
}
|
94
95
|
}
|
95
96
|
|
96
|
-
|
97
|
+
PaginationListView.propTypes = {
|
98
|
+
pageNum: PropTypes.number.isRequired,
|
99
|
+
onPageSelected: PropTypes.func.isRequired,
|
100
|
+
selected: PropTypes.number.isRequired,
|
101
|
+
pageClassName: PropTypes.string,
|
102
|
+
pageLinkClassName: PropTypes.string,
|
103
|
+
activeClassName: PropTypes.string,
|
104
|
+
pageRangeDisplayed: PropTypes.number.isRequired,
|
105
|
+
marginPagesDisplayed: PropTypes.number.isRequired,
|
106
|
+
breakLabel: PropTypes.node,
|
107
|
+
subContainerClassName: PropTypes.string,
|
108
|
+
};
|
109
|
+
|
110
|
+
export default PaginationListView;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import Initializer from '../components/admin/Initializer';
|
2
|
+
|
3
|
+
document.addEventListener('turbolinks:load', () => {
|
4
|
+
Initializer.initializeResourcesForm();
|
5
|
+
Initializer.initializeResourcesList();
|
6
|
+
Initializer.initializeSelectAll();
|
7
|
+
});
|
8
|
+
|
9
|
+
// Support component names relative to this directory:
|
10
|
+
// eslint-disable-next-line no-undef
|
11
|
+
const componentRequireContext = require.context('components', true);
|
12
|
+
// eslint-disable-next-line no-undef
|
13
|
+
const ReactRailsUJS = require('react_ujs');
|
14
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
15
|
+
ReactRailsUJS.useContext(componentRequireContext);
|
@@ -16,9 +16,10 @@
|
|
16
16
|
|
17
17
|
// Support component names relative to this directory:
|
18
18
|
// eslint-disable-next-line no-undef
|
19
|
-
const componentRequireContext = require.context('components', true)
|
19
|
+
const componentRequireContext = require.context('components', true);
|
20
20
|
// eslint-disable-next-line no-undef
|
21
|
-
const ReactRailsUJS = require('react_ujs')
|
22
|
-
|
21
|
+
const ReactRailsUJS = require('react_ujs');
|
22
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
23
|
+
ReactRailsUJS.useContext(componentRequireContext);
|
23
24
|
|
24
|
-
console.debug('Hello World from Webpacker FROM INSIDE `lcms-engine` gem!')
|
25
|
+
console.debug('Hello World from Webpacker FROM INSIDE `lcms-engine` gem!');
|
@@ -2,4 +2,5 @@
|
|
2
2
|
// It must expose react_ujs as `ReactRailsUJS` and prepare a require context.
|
3
3
|
const componentRequireContext = require.context('components', true);
|
4
4
|
const ReactRailsUJS = require('react_ujs');
|
5
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
5
6
|
ReactRailsUJS.useContext(componentRequireContext);
|