Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #146 from clint-tseng/cxlt/56
Browse files Browse the repository at this point in the history
export/new #56: allow title-on-phone to differ from title-in-Build.
  • Loading branch information
issa-tseng authored May 30, 2017
2 parents 11e9fd3 + 72f25b0 commit 5b1a7bf
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 3 deletions.
1 change: 1 addition & 0 deletions public/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions public/javascripts/data-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
16 changes: 14 additions & 2 deletions public/javascripts/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions public/javascripts/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
6 changes: 6 additions & 0 deletions public/stylesheets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,12 @@ body > .control.last .controlFlowArrow,
width: 40em;
}

.formPropertiesDialog input
{
margin-left: 10em;
width: calc(100% - 10em);
}

.errorMessage p
{
color: #f00;
Expand Down
18 changes: 17 additions & 1 deletion server/views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
<li class="disabled"><a href="#undo">Undo</a></li>
<li class="disabled"><a href="#redo">Redo</a></li>
<li class="divider"></li>
<li><a href="#translationsDialog" class="manageTranslations" rel="modal">Manage Translations...</a></li>
<li><a href="#translationsDialog" class="manageTranslations" rel="modal">Manage Translations&hellip;</a></li>
<li><a href="#formPropertiesDialog" class="formProperties" rel="modal">Form Properties&hellip;</a></li>
</ul>
</li>
<li>
Expand Down Expand Up @@ -292,6 +293,21 @@
</div>
</div>

<div class="modal narrowModal formPropertiesDialog">
<h3>Form Properties</h3>
<div class="modalContents">
<form>
<div class="errorMessage"></div>

<label for="formProperties_title">Title on Device</label>
<input type="text" id="formProperties_title" name="title" />
</form>
</div>
<div class="modalButtonContainer">
<a class="modalButton jqmClose" href="#close">Done</a>
</div>
</div>

<div class="modal narrowModal translationsDialog">
<h3>Translations</h3>
<div class="modalContents">
Expand Down

0 comments on commit 5b1a7bf

Please sign in to comment.