From a6eaa467873dc589e1f246fef9230c5c47cb42f6 Mon Sep 17 00:00:00 2001 From: Leszek Pietrzak Date: Fri, 4 Jan 2019 23:02:58 +0100 Subject: [PATCH 1/7] cleanup old FB header code --- jsapp/xlform/src/view.surveyApp.coffee | 39 -------------------------- 1 file changed, 39 deletions(-) diff --git a/jsapp/xlform/src/view.surveyApp.coffee b/jsapp/xlform/src/view.surveyApp.coffee index 86624f84ab..c4e6501996 100644 --- a/jsapp/xlform/src/view.surveyApp.coffee +++ b/jsapp/xlform/src/view.surveyApp.coffee @@ -52,7 +52,6 @@ module.exports = do -> "click #xlf-download": "downloadButtonClick" "click #save": "saveButtonClick" "click #publish": "publishButtonClick" - "click #settings": "toggleSurveySettings" "update-sort": "updateSort" "click .js-select-row": "selectRow" "click .js-select-row--force": "forceSelectRow" @@ -233,28 +232,6 @@ module.exports = do -> getApp: -> @ - toggleSurveySettings: (evt) -> - $et = $(evt.currentTarget) - $et.toggleClass('active__settings') - if @features.surveySettings - $settings = @$(".form__settings") - $settings.toggle() - close_settings = (e) -> - $settings_toggle = $('#settings') - - is_in_settings = (element) -> - element == $settings[0] || $settings.find(element).length > 0 - is_in_settings_toggle = (element) -> - element == $settings_toggle[0] || $settings_toggle.find(element).length > 0 - - if !(is_in_settings(e.target) || is_in_settings_toggle(e.target)) - $settings.hide() - $et.removeClass('active__settings') - $('body').off 'click', close_settings - - $('body').on 'click', close_settings - - _getViewForTarget: (evt)-> $et = $(evt.currentTarget) modelId = $et.closest('.survey__row').data('row-id') @@ -330,12 +307,6 @@ module.exports = do -> for key, value of validations break - if @features.displayTitle - $viewUtils.makeEditable @, @survey.settings, '.form-title', property:'form_title', options: validate: (value) -> - if value.length > 255 - return "Length cannot exceed 255 characters, is " + value.length + " characters." - return - $inps = {} _settings = @survey.settings @@ -376,12 +347,6 @@ module.exports = do -> @null_top_row_view_selector = new $viewRowSelector.RowSelector(el: @$el.find(".survey__row__spacer").get(0), survey: @survey, ngScope: @ngScope, surveyView: @, reversible:true) _render_hideConditionallyDisplayedContent: -> - if not @features.displayTitle - @$(".survey-header__inner").hide() - - if not @features.surveySettings - @$(".survey-header__options-toggle").hide() - if !@features.multipleQuestions @$el.addClass('survey-editor--singlequestion') @$el.find(".survey-editor__null-top-row").addClass("survey-editor__null-top-row--hidden") @@ -750,17 +715,13 @@ module.exports = do -> features: multipleQuestions: true skipLogic: true - displayTitle: true copyToLibrary: true - surveySettings: true class surveyApp.QuestionApp extends SurveyFragmentApp features: multipleQuestions: false skipLogic: false - displayTitle: false copyToLibrary: false - surveySettings: false render: () -> super @$('.survey-editor.form-editor-wrap.container').append $('.question__tags') From cb5b6d323c23d0a0e0f7f85d5dbfea461394e3fe Mon Sep 17 00:00:00 2001 From: Leszek Pietrzak Date: Fri, 4 Jan 2019 23:03:16 +0100 Subject: [PATCH 2/7] add debug logs --- jsapp/xlform/src/view.choices.coffee | 2 ++ jsapp/xlform/src/view.row.coffee | 2 ++ 2 files changed, 4 insertions(+) diff --git a/jsapp/xlform/src/view.choices.coffee b/jsapp/xlform/src/view.choices.coffee index da166bc3c6..069c5e0b3f 100644 --- a/jsapp/xlform/src/view.choices.coffee +++ b/jsapp/xlform/src/view.choices.coffee @@ -99,8 +99,10 @@ module.exports = do -> @options.cl.options.add(@model) @p.html("Option #{1+@options.i}").addClass("preliminary") + console.debug('makeEditable', @p) $viewUtils.makeEditable @, @model, @p, edit_callback: _.bind @saveValue, @ @n = $('span', @c) + console.debug('makeEditable', @n) $viewUtils.makeEditable @, @model, @n, edit_callback: (val) => other_names = @options.cl.getNames() if @model.get('name')? && val.toLowerCase() == @model.get('name').toLowerCase() diff --git a/jsapp/xlform/src/view.row.coffee b/jsapp/xlform/src/view.row.coffee index a85d1af433..65d48da97e 100644 --- a/jsapp/xlform/src/view.row.coffee +++ b/jsapp/xlform/src/view.row.coffee @@ -187,6 +187,7 @@ module.exports = do -> @$('.xlf-dv-appearance').eq(0).show() @ make_label_editable: (view) -> + console.debug('makeEditable make_label_editable', @$label) $viewUtils.makeEditable view, view.model, @$label, options: placement: 'right' rows: 3 @@ -238,6 +239,7 @@ module.exports = do -> @is_expanded = true return make_label_editable: (view) -> + console.debug('makeEditable make_label_editable', @$label) $viewUtils.makeEditable view, view.model, @$label, options: placement: 'right' rows: 3 From 66b68a1198a4a3c0d6344ac486ab44c2d5b72ec9 Mon Sep 17 00:00:00 2001 From: Leszek Pietrzak Date: Fri, 4 Jan 2019 23:03:29 +0100 Subject: [PATCH 3/7] print error for makeEditable if el not found --- jsapp/xlform/src/view.utils.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jsapp/xlform/src/view.utils.coffee b/jsapp/xlform/src/view.utils.coffee index b321489856..7e094fba4f 100644 --- a/jsapp/xlform/src/view.utils.coffee +++ b/jsapp/xlform/src/view.utils.coffee @@ -14,8 +14,12 @@ module.exports = do -> viewUtils.makeEditable = (that, model, selector, {property, transformFunction, options, edit_callback}) -> if !(selector instanceof jQuery) + origSelector = selector selector =that.$el.find(selector) + if selector.length is 0 + console?.error("makeEditable called on nonexistent element:", origSelector) + if selector.data('madeEditable') console?.error "makeEditable called 2x on the same element: ", selector selector.data('madeEditable', true) @@ -74,7 +78,6 @@ module.exports = do -> selector.on 'click', enable_edit - #selector.editable editableOpts viewUtils.reorderElemsByData = (selector, parent, dataAttribute)-> From a68fe5483e706c3abeb9d042d5aaffb95d6e4bd4 Mon Sep 17 00:00:00 2001 From: Leszek Pietrzak Date: Fri, 4 Jan 2019 23:03:48 +0100 Subject: [PATCH 4/7] change card header title to input --- jsapp/xlform/src/view.row.templates.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jsapp/xlform/src/view.row.templates.coffee b/jsapp/xlform/src/view.row.templates.coffee index 07a7068f6c..ed179e28d2 100644 --- a/jsapp/xlform/src/view.row.templates.coffee +++ b/jsapp/xlform/src/view.row.templates.coffee @@ -62,7 +62,7 @@ module.exports = do ->
- +
@@ -105,7 +105,7 @@ module.exports = do ->
- +
From 54d58a0e6b5525fba10a3c0f5bbef3f0be15255d Mon Sep 17 00:00:00 2001 From: Leszek Pietrzak Date: Mon, 7 Jan 2019 14:36:06 +0100 Subject: [PATCH 5/7] fix input text colors --- jsapp/scss/stylesheets/partials/_registration.scss | 2 +- .../stylesheets/partials/form_builder/_card.scss | 13 +++++++++++-- .../partials/form_builder/_card_multichoice.scss | 5 ----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/jsapp/scss/stylesheets/partials/_registration.scss b/jsapp/scss/stylesheets/partials/_registration.scss index c10824342a..870b51e6ff 100644 --- a/jsapp/scss/stylesheets/partials/_registration.scss +++ b/jsapp/scss/stylesheets/partials/_registration.scss @@ -250,7 +250,7 @@ .error-message { font-size: 14px; color: $cool-red; - background-color: rgba(255, 0, 0, 0.075); + background-color: rgba($cool-red, 0.075); } .registration__credit { diff --git a/jsapp/scss/stylesheets/partials/form_builder/_card.scss b/jsapp/scss/stylesheets/partials/form_builder/_card.scss index 13dfdd8295..1bcbf166fa 100644 --- a/jsapp/scss/stylesheets/partials/form_builder/_card.scss +++ b/jsapp/scss/stylesheets/partials/form_builder/_card.scss @@ -62,8 +62,17 @@ } .card__header-title { - cursor:text; - // white-space: pre; + color: $cool-gray; + + &:focus { + color: $black; + } + + // we use placeholder as error message, as empty title is not welcomed + &::placeholder { + color: $cool-red; + background-color: rgba($cool-red, 0.075); + } } .card__header-subtitle { margin: 10px 0 0 0; diff --git a/jsapp/scss/stylesheets/partials/form_builder/_card_multichoice.scss b/jsapp/scss/stylesheets/partials/form_builder/_card_multichoice.scss index dc1053426f..db4ca5bfc1 100644 --- a/jsapp/scss/stylesheets/partials/form_builder/_card_multichoice.scss +++ b/jsapp/scss/stylesheets/partials/form_builder/_card_multichoice.scss @@ -39,11 +39,6 @@ .row__multioptions { display: block; } - - .card__buttons__multioptions, - .card__buttons__multioptions + .card__header-title { - color: $indicatorColor; - } } } From 0a35b48a80264c57ec1d1452e0d47e7cb283a565 Mon Sep 17 00:00:00 2001 From: Leszek Pietrzak Date: Mon, 7 Jan 2019 14:36:43 +0100 Subject: [PATCH 6/7] remove make_label_editable code, use simpler listenForInputChange --- jsapp/xlform/src/view.row.coffee | 30 ---------------------- jsapp/xlform/src/view.row.templates.coffee | 4 +-- jsapp/xlform/src/view.rowDetail.coffee | 13 ++++++++-- 3 files changed, 13 insertions(+), 34 deletions(-) diff --git a/jsapp/xlform/src/view.row.coffee b/jsapp/xlform/src/view.row.coffee index 65d48da97e..aa3e3b3f08 100644 --- a/jsapp/xlform/src/view.row.coffee +++ b/jsapp/xlform/src/view.row.coffee @@ -86,8 +86,6 @@ module.exports = do -> @model.finalize() val.set('value', '') view.render().insertInDOM(@) - if key == 'label' - @make_label_editable(view) if @model.getValue('required') @$card.addClass('card--required') @ @@ -155,10 +153,6 @@ module.exports = do -> @model.rows.each (row)=> @getApp().ensureElInView(row, @, @$rows).render() - if !@already_rendered - # only render the row details which are necessary for the initial view (ie 'label') - @make_label_editable new $viewRowDetail.DetailView(model: @model.get('label'), rowView: @).render().insertInDOM(@) - @already_rendered = true @ @@ -186,21 +180,6 @@ module.exports = do -> if row.constructor.key == 'group' && !@hasNestedGroups() @$('.xlf-dv-appearance').eq(0).show() @ - make_label_editable: (view) -> - console.debug('makeEditable make_label_editable', @$label) - $viewUtils.makeEditable view, view.model, @$label, options: - placement: 'right' - rows: 3 - , - edit_callback: (value) -> - value = value.replace(new RegExp(String.fromCharCode(160), 'g'), '') - value = value.replace /\t/g, ' ' - view.model.set 'value', value - - if value == '' - return newValue: new Array(10).join(' ') - else - return newValue: value; class RowView extends BaseRowView _expandedRender: -> @@ -238,13 +217,6 @@ module.exports = do -> @showMultioptions() @is_expanded = true return - make_label_editable: (view) -> - console.debug('makeEditable make_label_editable', @$label) - $viewUtils.makeEditable view, view.model, @$label, options: - placement: 'right' - rows: 3 - , - transformFunction: (value) -> value class KoboMatrixView extends RowView className: "survey__row survey__row--kobo-matrix" @@ -269,8 +241,6 @@ module.exports = do -> @model.finalize() val.set('value', '') view.render().insertInDOM(@) - if key == 'label' - @make_label_editable(view) @ class RankScoreView extends RowView diff --git a/jsapp/xlform/src/view.row.templates.coffee b/jsapp/xlform/src/view.row.templates.coffee index ed179e28d2..0c445026eb 100644 --- a/jsapp/xlform/src/view.row.templates.coffee +++ b/jsapp/xlform/src/view.row.templates.coffee @@ -62,7 +62,7 @@ module.exports = do ->
- +
@@ -105,7 +105,7 @@ module.exports = do ->
- +
diff --git a/jsapp/xlform/src/view.rowDetail.coffee b/jsapp/xlform/src/view.rowDetail.coffee index 3c1162e5c5..d899d22de8 100644 --- a/jsapp/xlform/src/view.rowDetail.coffee +++ b/jsapp/xlform/src/view.rowDetail.coffee @@ -157,8 +157,17 @@ module.exports = do -> html: -> false insertInDOM: (rowView)-> cht = rowView.$label - cht.html(@model.get("value")|| new Array(10).join(' ')) - @ + cht.value = @model.get('value') + return @ + afterRender: -> + @listenForInputChange({ + el: this.rowView.$label, + transformFn: (value) -> + value = value.replace(new RegExp(String.fromCharCode(160), 'g'), '') + value = value.replace /\t/g, ' ' + return value + }) + return viewRowDetail.DetailViewMixins.hint = html: -> From 5912a373f2f43a6affb28abfacbeee67b082ee6a Mon Sep 17 00:00:00 2001 From: Leszek Pietrzak Date: Mon, 7 Jan 2019 15:35:38 +0100 Subject: [PATCH 7/7] remove debug logs --- jsapp/xlform/src/view.choices.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/jsapp/xlform/src/view.choices.coffee b/jsapp/xlform/src/view.choices.coffee index 069c5e0b3f..da166bc3c6 100644 --- a/jsapp/xlform/src/view.choices.coffee +++ b/jsapp/xlform/src/view.choices.coffee @@ -99,10 +99,8 @@ module.exports = do -> @options.cl.options.add(@model) @p.html("Option #{1+@options.i}").addClass("preliminary") - console.debug('makeEditable', @p) $viewUtils.makeEditable @, @model, @p, edit_callback: _.bind @saveValue, @ @n = $('span', @c) - console.debug('makeEditable', @n) $viewUtils.makeEditable @, @model, @n, edit_callback: (val) => other_names = @options.cl.getNames() if @model.get('name')? && val.toLowerCase() == @model.get('name').toLowerCase()