Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 5af37f8

Browse files
committed
Merge pull request #3286 from TomMalbran/tom/project-template-vars
[OPEN] Move the Project Preferences Dialog variables to the template
2 parents 7fbcc4a + 79bbd1e commit 5af37f8

2 files changed

Lines changed: 29 additions & 36 deletions

File tree

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<div class="project-settings-dialog modal">
22
<div class="modal-header">
3-
<h1 class="dialog-title"></h1>
3+
<h1 class="dialog-title">{{title}}</h1>
44
</div>
55
<div class="modal-body">
66
<div class="field-container">
7-
<label>{{PROJECT_SETTING_BASE_URL}}: <input type="text" placeholder="{{PROJECT_SETTING_BASE_URL_HINT}}" class="url" /></label>
8-
</div>
7+
<label>
8+
{{Strings.PROJECT_SETTING_BASE_URL}}: <input type="text" placeholder="{{Strings.PROJECT_SETTING_BASE_URL_HINT}}" value="{{baseUrl}}" class="url" />
9+
</label>
10+
{{#errorMessage}}<div class="alert" style="margin-bottom: 0">{{{errorMessage}}}</div>{{/errorMessage}}
11+
</div>
912
</div>
1013
<div class="modal-footer">
11-
<button class="dialog-button btn" data-button-id="cancel">{{CANCEL}}</button>
12-
<button class="dialog-button btn primary" data-button-id="ok">{{OK}}</button>
14+
<button class="dialog-button btn" data-button-id="cancel">{{Strings.CANCEL}}</button>
15+
<button class="dialog-button btn primary" data-button-id="ok">{{Strings.OK}}</button>
1316
</div>
1417
</div>

src/preferences/PreferencesDialogs.js

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,27 @@ define(function (require, exports, module) {
8080
* of the clicked button when the dialog is dismissed. Never rejected.
8181
*/
8282
function showProjectPreferencesDialog(baseUrl, errorMessage) {
83-
var $dlg,
84-
$title,
85-
$baseUrlControl,
83+
var $baseUrlControl,
8684
dialog;
87-
88-
dialog = Dialogs.showModalDialogUsingTemplate(Mustache.render(SettingsDialogTemplate, Strings));
89-
85+
86+
// Title
87+
var projectName = "",
88+
projectRoot = ProjectManager.getProjectRoot(),
89+
title;
90+
if (projectRoot) {
91+
projectName = projectRoot.name;
92+
}
93+
title = StringUtils.format(Strings.PROJECT_SETTINGS_TITLE, projectName);
94+
95+
var templateVars = {
96+
title : title,
97+
baseUrl : baseUrl,
98+
errorMessage : errorMessage,
99+
Strings : Strings
100+
};
101+
102+
dialog = Dialogs.showModalDialogUsingTemplate(Mustache.render(SettingsDialogTemplate, templateVars));
103+
90104
dialog.done(function (id) {
91105
if (id === Dialogs.DIALOG_BTN_OK) {
92106
var baseUrlValue = $baseUrlControl.val();
@@ -100,32 +114,8 @@ define(function (require, exports, module) {
100114
}
101115
});
102116

103-
// Populate project settings
104-
$dlg = dialog.getElement();
105-
106-
// Title
107-
$title = $dlg.find(".dialog-title");
108-
var projectName = "",
109-
projectRoot = ProjectManager.getProjectRoot(),
110-
title;
111-
if (projectRoot) {
112-
projectName = projectRoot.name;
113-
}
114-
title = StringUtils.format(Strings.PROJECT_SETTINGS_TITLE, projectName);
115-
$title.text(title);
116-
117-
// Base URL
118-
$baseUrlControl = $dlg.find(".url");
119-
if (baseUrl) {
120-
$baseUrlControl.val(baseUrl);
121-
}
122-
123-
// Error message
124-
if (errorMessage) {
125-
$dlg.find(".field-container").append("<div class='alert' style='margin-bottom: 0'>" + errorMessage + "</div>");
126-
}
127-
128117
// Give focus to first control
118+
$baseUrlControl = dialog.getElement().find(".url");
129119
$baseUrlControl.focus();
130120

131121
return dialog;

0 commit comments

Comments
 (0)