diff --git a/public/javascripts/application.js b/public/javascripts/application.js index e9c89dba..a0c64294 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -12,6 +12,7 @@ applicationNS.newForm = function() $('.control').trigger('odkControl-removed'); $('.workspace').empty(); $('.header h1').text('Untitled Form'); + $('#formProperties_title').val(''); applicationNS.clearProperties(); odkmaker.data.currentForm = null; odkmaker.data.clean = true; diff --git a/public/javascripts/data-ui.js b/public/javascripts/data-ui.js index 373bd9aa..19d126d3 100644 --- a/public/javascripts/data-ui.js +++ b/public/javascripts/data-ui.js @@ -297,5 +297,13 @@ var dataNS = odkmaker.namespace.load('odkmaker.data'); complete: function() { $loading.hide(); } }); }); + + $('.formPropertiesDialog .jqmClose').on('click', function() + { + // this codebase is really starting to wear. we have to clear out this field + // if it is identical to the main title so it doesn't get picked up. + var $input = $('#formProperties_title'); + if ($input.val() === $('h1').text()) $input.val(''); + }); }); })(jQuery); diff --git a/public/javascripts/data.js b/public/javascripts/data.js index 5765e99d..c2394ba7 100644 --- a/public/javascripts/data.js +++ b/public/javascripts/data.js @@ -34,16 +34,27 @@ var dataNS = odkmaker.namespace.load('odkmaker.data'); }; odkmaker.data.extract = function() { + var htitle = odkmaker.data.getTitle(); + if ($.isBlank(htitle) || (htitle === $('h1').text())) htitle = null; + return { title: $('h1').text(), controls: extractMany($('.workspace')), metadata: { version: odkmaker.data.currentVersion, activeLanguages: odkmaker.i18n.activeLanguageData(), - optionsPresets: odkmaker.options.presets + optionsPresets: odkmaker.options.presets, + htitle: htitle } }; }; + odkmaker.data.getTitle = function() + { + var title = $('#formProperties_title').val(); + if ($.isBlank(title) && (odkmaker.data.currentForm != null)) title = odkmaker.data.currentForm.metadata.title; + if ($.isBlank(title)) title = $('h1').text(); + return title; + }; var loadOne = odkmaker.data.loadOne = function(control) { @@ -94,6 +105,7 @@ var dataNS = odkmaker.namespace.load('odkmaker.data'); $('.workspace').empty(); $('h1').text(formObj.title); + $('#formProperties_title').val(formObj.metadata.htitle) odkmaker.i18n.setActiveLanguages(formObj.metadata.activeLanguages); odkmaker.options.presets = formObj.metadata.optionsPresets; loadMany($('.workspace'), formObj.controls); @@ -599,7 +611,7 @@ var dataNS = odkmaker.namespace.load('odkmaker.data'); { name: 'h:head', children: [ { name: 'h:title', - val: internal.title }, + val: odkmaker.data.getTitle() }, model ] }, body diff --git a/public/javascripts/modals.js b/public/javascripts/modals.js index 58e521e1..8809df99 100644 --- a/public/javascripts/modals.js +++ b/public/javascripts/modals.js @@ -70,6 +70,12 @@ var modalsNS = odkmaker.namespace.load('odkmaker.modals'); { $dialog.removeClass('exporting'); }, + formPropertiesDialog: function($dialog) + { + $dialog.find('#formProperties_title') + .attr('placeholder', $('h1').text()) + .val(odkmaker.data.getTitle()); + }, optionsEditorDialog: odkmaker.options.modalHandler }; diff --git a/public/stylesheets/styles.css b/public/stylesheets/styles.css index 754faac9..61306aeb 100644 --- a/public/stylesheets/styles.css +++ b/public/stylesheets/styles.css @@ -1372,6 +1372,12 @@ body > .control.last .controlFlowArrow, width: 40em; } +.formPropertiesDialog input +{ + margin-left: 10em; + width: calc(100% - 10em); +} + .errorMessage p { color: #f00; diff --git a/server/views/index.erb b/server/views/index.erb index 46e905ac..a62e13e0 100644 --- a/server/views/index.erb +++ b/server/views/index.erb @@ -79,7 +79,8 @@
  • Undo
  • Redo
  • -
  • Manage Translations...
  • +
  • Manage Translations…
  • +
  • Form Properties…
  • @@ -292,6 +293,21 @@ + +