diff --git a/app/components/big-text.js b/app/components/big-text.js index 710a787595..4a51c78971 100644 --- a/app/components/big-text.js +++ b/app/components/big-text.js @@ -1,5 +1,9 @@ import Ember from 'ember'; +const {computed, Handlebars} = Ember; +const {SafeString} = Handlebars; +const {collect, sum} = computed; + export default Ember.Component.extend({ expanded: false, classNames: ['big-text'], @@ -8,28 +12,36 @@ export default Ember.Component.extend({ expandIcon: 'info-circle', text: '', ellipsis: 'ellipsis-h', - lengths: Ember.computed.collect('length', 'slippage'), - totalLength: Ember.computed.sum('lengths'), - promptText: '', - showIcons: function(){ - return this.get('displayText') !== this.get('cleanText'); - }.property('displayText', 'text'), - cleanText: function(){ - var text = this.get('text'); - if(text === undefined || text == null){ - return this.get('promptText')?this.get('promptText').toString():''; + lengths: collect('length', 'slippage'), + totalLength: sum('lengths'), + renderHtml: true, + showIcons: computed('displayText', 'text', 'renderHtml', function(){ + if(this.get('renderHtml')){ + return this.get('displayText').toString() !== this.get('text'); + } else { + return this.get('displayText').toString() !== this.get('cleanText'); } + }), + cleanText: computed('text', function(){ //strip any possible HTML out of the text - return text.replace(/(<([^>]+)>)/ig,""); - }.property('text'), - displayText: function(){ - var text = this.get('cleanText'); - if(this.get('expanded') || text.length < this.get('totalLength')){ - return text; + return this.get('text').replace(/(<([^>]+)>)/ig,""); + }), + displayText: computed('cleanText', 'totalLength', 'length', 'expanded', function(){ + let cleanText = this.get('cleanText'); + let text; + if(this.get('expanded') || cleanText.length < this.get('totalLength')){ + if(this.get('renderHtml')){ + text = this.get('text'); + } else { + text = cleanText; + } + } else { + text = cleanText.substring(0, this.get('length')); } - - return text.substring(0, this.get('length')); - }.property('cleanText', 'totalLength', 'length', 'expanded'), + + return new SafeString(text); + + }), actions: { click: function(){ this.sendAction(); diff --git a/app/components/detail-objectives.js b/app/components/detail-objectives.js index 887e9cbdce..671235885b 100644 --- a/app/components/detail-objectives.js +++ b/app/components/detail-objectives.js @@ -1,24 +1,32 @@ import Ember from 'ember'; import scrollTo from '../utils/scroll-to'; +import config from 'ilios/config/environment'; + +const {computed, inject} = Ember; +const {service} = inject; +const {or, notEmpty} = computed; export default Ember.Component.extend({ - store: Ember.inject.service(), + store: service(), + flashMessages: service(), subject: null, classNames: ['detail-objectives'], isCourse: false, isSession: false, isProgramYear: false, - isManaging: Ember.computed.or('isManagingParents', 'isManagingDescriptors', 'isManagingCompetency'), - isManagingParents: Ember.computed.notEmpty('mangeParentsObjective'), + isManaging: or('isManagingParents', 'isManagingDescriptors', 'isManagingCompetency'), + isManagingParents: notEmpty('mangeParentsObjective'), mangeParentsObjective: null, initialStateForManageParentsObjective: [], - isManagingDescriptors: Ember.computed.notEmpty('manageDescriptorsObjective'), + isManagingDescriptors: notEmpty('manageDescriptorsObjective'), mangeMeshObjective: null, initialStateForManageMeshObjective: [], - isManagingCompetency: Ember.computed.notEmpty('manageCompetencyObjective'), + isManagingCompetency: notEmpty('manageCompetencyObjective'), manageCompetencyObjective: null, initialStateForManageCompetencyObjective: null, - newObjectives: [], + newObjectiveEditorOn: false, + newObjectiveTitle: null, + editorParams: config.froalaEditorDefaults, actions: { manageParents: function(objective){ objective.get('parents').then((parents) => { @@ -125,13 +133,9 @@ export default Ember.Component.extend({ scrollTo("#objective-" + objective.get('id')); } }, - addObjective: function(){ - var objective = this.get('store').createRecord('objective'); - this.get('newObjectives').addObject(objective); - }, - saveNewObjective: function(newObjective){ - var self = this; - self.get('newObjectives').removeObject(newObjective); + saveNewObjective: function(){ + let newObjective = this.get('store').createRecord('objective'); + newObjective.set('title', this.get('newObjectiveTitle')); if(this.get('isCourse')){ newObjective.get('courses').addObject(this.get('subject')); } @@ -141,15 +145,26 @@ export default Ember.Component.extend({ if(this.get('isProgramYear')){ newObjective.get('programYears').addObject(this.get('subject')); } - newObjective.save().then(function(savedObjective){ - self.get('subject.objectives').then(function(objectives){ + newObjective.save().then(savedObjective => { + this.get('subject.objectives').then(objectives => { objectives.addObject(savedObjective); - objectives.save(); }); + this.send('closeNewObjectiveEditor'); + this.get('flashMessages').success('courses.newObjectiveSaved'); }); }, - removeNewObjective: function(newObjective){ - this.get('newObjectives').removeObject(newObjective); + toggleNewObjectiveEditor() { + this.set('newObjectiveTitle', null); + this.set('newObjectiveEditorOn', !this.get('newObjectiveEditorOn')); + }, + closeNewObjectiveEditor() { + this.set('newObjectiveTitle', null); + this.set('newObjectiveEditorOn', false); + }, + changeNewObjectiveTitle(event, editor){ + if(editor){ + this.set('newObjectiveTitle', editor.getHTML()); + } }, } }); diff --git a/app/components/inplace-html.js b/app/components/inplace-html.js new file mode 100644 index 0000000000..40b280cb40 --- /dev/null +++ b/app/components/inplace-html.js @@ -0,0 +1,18 @@ +import Ember from 'ember'; +import config from 'ilios/config/environment'; +import InPlace from 'ilios/mixins/inplace'; + +export default Ember.Component.extend(InPlace, { + classNames: ['editinplace', 'inplace-html'], + editorParams: config.froalaEditorDefaults, + willDestroyElement(){ + this.$('.control .froala-box').editable('destroy'); + }, + actions: { + grabChangedValue: function(event, editor){ + if(editor){ + this.send('changeValue', editor.getHTML()); + } + } + } +}); diff --git a/app/components/new-learningmaterial.js b/app/components/new-learningmaterial.js index dde2f270bc..ec9cb8e59c 100644 --- a/app/components/new-learningmaterial.js +++ b/app/components/new-learningmaterial.js @@ -1,4 +1,5 @@ import Ember from 'ember'; +import config from 'ilios/config/environment'; import layout from '../templates/components/new-learningmaterial'; export default Ember.Component.extend({ @@ -17,6 +18,7 @@ export default Ember.Component.extend({ isCitation: function(){ return this.get('learningMaterial.type') === 'citation'; }.property('learningMaterial.type'), + editorParams: config.froalaEditorDefaults, actions: { save: function(){ this.sendAction('save', this.get('learningMaterial')); @@ -41,6 +43,11 @@ export default Ember.Component.extend({ let learningMaterialUserRoles = this.get('learningMaterialUserRoles'); let role = learningMaterialUserRoles.toArray()[selectedIndex]; this.set('learningMaterial.userRole', role); - } + }, + changeDescription(event, editor){ + if(editor){ + this.get('learningMaterial').set('description', editor.getHTML()); + } + }, } }); diff --git a/app/locales/en/translations.js b/app/locales/en/translations.js index e143d920c2..1ecc59243e 100644 --- a/app/locales/en/translations.js +++ b/app/locales/en/translations.js @@ -203,6 +203,7 @@ export default { 'title': 'Course Title', 'objectiveParentTitle': 'Select Parent Objectives', 'objectiveDescriptorTitle': 'Select MeSH Descriptors', + 'newObjectiveSaved': 'New Objective Saved', 'chooseCohortTitle': 'Select Parent For', 'missingCohortMessage': 'Please add at least one cohort to this course.', 'confirmRemove': 'Are you sure you want to delete this course, with {{publishedOfferingCount}} published offerings? This action will remove all sessions and offerings for this course, and cannot be undone.', diff --git a/app/locales/es/translations.js b/app/locales/es/translations.js index eb0ee83787..63cd714559 100644 --- a/app/locales/es/translations.js +++ b/app/locales/es/translations.js @@ -203,6 +203,7 @@ export default { 'title': 'Titulo de Curso', 'objectiveParentTitle': 'Seleccione Objetivos Principales', 'objectiveDescriptorTitle': 'Seleccione Descriptores de MeSH', + 'newObjectiveSaved': 'Nuevo Objetivo Guardado', 'chooseCohortTitle': 'Seleccione Matriz Para', 'missingCohortMessage': 'Favor de agregar por lo menos un Clase de La Graduación a este curso.', 'confirmRemove': ' ¿Estás seguro que quieres borrar este curso, con {{publishedOfferingCount}} ofrecimientos publicados? Esta acción borrará todas las sessiones y ofrecimientos para este curso y no se puede deshacer.', diff --git a/app/locales/fr/translations.js b/app/locales/fr/translations.js index 497365a42a..d7c181d766 100755 --- a/app/locales/fr/translations.js +++ b/app/locales/fr/translations.js @@ -203,6 +203,7 @@ export default { 'title': "Titre de Cours", 'objectiveParentTitle': "Choisi Objectifs mères", 'objectiveDescriptorTitle': "Choisi MeSH", + 'newObjectiveSaved': 'Nouvel objective sauvé', 'chooseCohortTitle': "Choisi objectif mère pour", 'missingCohortMessage': "S'il vous plait ajouter au moins un cohort à ce cours.", 'confirmRemove': "Êtes-vous sûr vous voulez supprimer ce cours, avec {{publishedOfferingCount}} offres publié? Cela supprimera toutes sessions et offres pour ce cours, et ne peut pas être défait.", diff --git a/app/mirage/fixtures/objectives.js b/app/mirage/fixtures/objectives.js index 66c1e77cd5..19dfc2db07 100644 --- a/app/mirage/fixtures/objectives.js +++ b/app/mirage/fixtures/objectives.js @@ -961,7 +961,7 @@ export default [ { 'id' : 76350, - 'title' : "Describe and explain the general organization of the body and, in more detail, the anatomy of the musculoskeletal and nervous systems, including selected features of embryological development (early development, gastrulation, neurulation, segmentation, & development of the musculoskeletal system).
", + 'title' : "Describe and explain the general organization of the body and, in more detail, the anatomy of the musculoskeletal and nervous systems, including selected features of embryological development (early development, gastrulation, neurulation, segmentation, &
  1. First
development of the musculoskeletal system).
", 'courses' : [ '595' ], 'programYears' : [], 'sessions' : [], @@ -2820,4 +2820,4 @@ export default [ 'children' : [], 'meshDescriptors' : [] }, -]; \ No newline at end of file +]; diff --git a/app/styles/components/_global.scss b/app/styles/components/_global.scss index f54d5d278a..bcb4fb49b3 100644 --- a/app/styles/components/_global.scss +++ b/app/styles/components/_global.scss @@ -316,3 +316,30 @@ select:hover { ::-webkit-scrollbar-thumb:window-inactive { background: rgba(0, 0, 0, .05); } + +.list-reset { + ul { + list-style-position: inside; + list-style-type: disc; + } + + ol { + list-style-position: inside; + list-style-type: decimal; + } + + ul ul, + ol ul { + list-style-position: inside; + list-style-type: circle; + margin-left: 15px; + } + + ol ol, + ul ol { + list-style-position: inside; + list-style-type: lower-latin; + margin-left: 15px; + } + +} diff --git a/app/templates/components/.gitkeep b/app/templates/components/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/app/templates/components/big-text.hbs b/app/templates/components/big-text.hbs index 9d28b09134..7b4658b164 100644 --- a/app/templates/components/big-text.hbs +++ b/app/templates/components/big-text.hbs @@ -1,4 +1,4 @@ -{{displayText}} +{{displayText}} {{#if showIcons}} {{fa-icon ellipsis classNames='text-bottom'}} {{fa-icon expandIcon}} diff --git a/app/templates/components/course-objective-list.hbs b/app/templates/components/course-objective-list.hbs index 186d912654..7bb3d01ba6 100644 --- a/app/templates/components/course-objective-list.hbs +++ b/app/templates/components/course-objective-list.hbs @@ -10,7 +10,7 @@ {{#each sortedObjectives as |objective|}} - {{inplace-textarea value=objective.title save='changeObjectiveTitle' condition=objective.id}} + {{inplace-html value=objective.title save='changeObjectiveTitle' condition=objective.id}} {{#if objective.hasParents}} diff --git a/app/templates/components/course-objective-manager.hbs b/app/templates/components/course-objective-manager.hbs index c3a0d75f2a..744d23718f 100644 --- a/app/templates/components/course-objective-manager.hbs +++ b/app/templates/components/course-objective-manager.hbs @@ -1,4 +1,4 @@ -

{{{courseObjective.title}}}

+
{{{courseObjective.title}}}
{{#liquid-if showCohortList class="horizontal"}}