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

Commit 5b1a7bf

Browse files
authored
Merge pull request #146 from clint-tseng/cxlt/56
export/new #56: allow title-on-phone to differ from title-in-Build.
2 parents 11e9fd3 + 72f25b0 commit 5b1a7bf

File tree

6 files changed

+52
-3
lines changed

6 files changed

+52
-3
lines changed

public/javascripts/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ applicationNS.newForm = function()
1212
$('.control').trigger('odkControl-removed');
1313
$('.workspace').empty();
1414
$('.header h1').text('Untitled Form');
15+
$('#formProperties_title').val('');
1516
applicationNS.clearProperties();
1617
odkmaker.data.currentForm = null;
1718
odkmaker.data.clean = true;

public/javascripts/data-ui.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,5 +297,13 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');
297297
complete: function() { $loading.hide(); }
298298
});
299299
});
300+
301+
$('.formPropertiesDialog .jqmClose').on('click', function()
302+
{
303+
// this codebase is really starting to wear. we have to clear out this field
304+
// if it is identical to the main title so it doesn't get picked up.
305+
var $input = $('#formProperties_title');
306+
if ($input.val() === $('h1').text()) $input.val('');
307+
});
300308
});
301309
})(jQuery);

public/javascripts/data.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,27 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');
3434
};
3535
odkmaker.data.extract = function()
3636
{
37+
var htitle = odkmaker.data.getTitle();
38+
if ($.isBlank(htitle) || (htitle === $('h1').text())) htitle = null;
39+
3740
return {
3841
title: $('h1').text(),
3942
controls: extractMany($('.workspace')),
4043
metadata: {
4144
version: odkmaker.data.currentVersion,
4245
activeLanguages: odkmaker.i18n.activeLanguageData(),
43-
optionsPresets: odkmaker.options.presets
46+
optionsPresets: odkmaker.options.presets,
47+
htitle: htitle
4448
}
4549
};
4650
};
51+
odkmaker.data.getTitle = function()
52+
{
53+
var title = $('#formProperties_title').val();
54+
if ($.isBlank(title) && (odkmaker.data.currentForm != null)) title = odkmaker.data.currentForm.metadata.title;
55+
if ($.isBlank(title)) title = $('h1').text();
56+
return title;
57+
};
4758

4859
var loadOne = odkmaker.data.loadOne = function(control)
4960
{
@@ -94,6 +105,7 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');
94105
$('.workspace').empty();
95106

96107
$('h1').text(formObj.title);
108+
$('#formProperties_title').val(formObj.metadata.htitle)
97109
odkmaker.i18n.setActiveLanguages(formObj.metadata.activeLanguages);
98110
odkmaker.options.presets = formObj.metadata.optionsPresets;
99111
loadMany($('.workspace'), formObj.controls);
@@ -599,7 +611,7 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');
599611
{ name: 'h:head',
600612
children: [
601613
{ name: 'h:title',
602-
val: internal.title },
614+
val: odkmaker.data.getTitle() },
603615
model
604616
] },
605617
body

public/javascripts/modals.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ var modalsNS = odkmaker.namespace.load('odkmaker.modals');
7070
{
7171
$dialog.removeClass('exporting');
7272
},
73+
formPropertiesDialog: function($dialog)
74+
{
75+
$dialog.find('#formProperties_title')
76+
.attr('placeholder', $('h1').text())
77+
.val(odkmaker.data.getTitle());
78+
},
7379
optionsEditorDialog: odkmaker.options.modalHandler
7480
};
7581

public/stylesheets/styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,12 @@ body > .control.last .controlFlowArrow,
13721372
width: 40em;
13731373
}
13741374

1375+
.formPropertiesDialog input
1376+
{
1377+
margin-left: 10em;
1378+
width: calc(100% - 10em);
1379+
}
1380+
13751381
.errorMessage p
13761382
{
13771383
color: #f00;

server/views/index.erb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@
7979
<li class="disabled"><a href="#undo">Undo</a></li>
8080
<li class="disabled"><a href="#redo">Redo</a></li>
8181
<li class="divider"></li>
82-
<li><a href="#translationsDialog" class="manageTranslations" rel="modal">Manage Translations...</a></li>
82+
<li><a href="#translationsDialog" class="manageTranslations" rel="modal">Manage Translations&hellip;</a></li>
83+
<li><a href="#formPropertiesDialog" class="formProperties" rel="modal">Form Properties&hellip;</a></li>
8384
</ul>
8485
</li>
8586
<li>
@@ -292,6 +293,21 @@
292293
</div>
293294
</div>
294295

296+
<div class="modal narrowModal formPropertiesDialog">
297+
<h3>Form Properties</h3>
298+
<div class="modalContents">
299+
<form>
300+
<div class="errorMessage"></div>
301+
302+
<label for="formProperties_title">Title on Device</label>
303+
<input type="text" id="formProperties_title" name="title" />
304+
</form>
305+
</div>
306+
<div class="modalButtonContainer">
307+
<a class="modalButton jqmClose" href="#close">Done</a>
308+
</div>
309+
</div>
310+
295311
<div class="modal narrowModal translationsDialog">
296312
<h3>Translations</h3>
297313
<div class="modalContents">

0 commit comments

Comments
 (0)