Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/htmlContent/project-settings-dialog.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<div class="project-settings-dialog modal">
<div class="modal-header">
<h1 class="dialog-title"></h1>
<h1 class="dialog-title">{{title}}</h1>
</div>
<div class="modal-body">
<div class="field-container">
<label>{{PROJECT_SETTING_BASE_URL}}: <input type="text" placeholder="{{PROJECT_SETTING_BASE_URL_HINT}}" class="url" /></label>
</div>
<label>
{{Strings.PROJECT_SETTING_BASE_URL}}: <input type="text" placeholder="{{Strings.PROJECT_SETTING_BASE_URL_HINT}}" value="{{baseUrl}}" class="url" />
</label>
{{#errorMessage}}<div class="alert" style="margin-bottom: 0">{{{errorMessage}}}</div>{{/errorMessage}}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to re-add the third curly brace since the error string used is BASEURL_ERROR_INVALID_PROTOCOL which uses $mdash;. So I need to tell Mustache to parse this string as HTML and not just as plain text to display the dash correctly. If the string is modified, we can remove the third curly brace.

</div>
</div>
<div class="modal-footer">
<button class="dialog-button btn" data-button-id="cancel">{{CANCEL}}</button>
<button class="dialog-button btn primary" data-button-id="ok">{{OK}}</button>
<button class="dialog-button btn" data-button-id="cancel">{{Strings.CANCEL}}</button>
<button class="dialog-button btn primary" data-button-id="ok">{{Strings.OK}}</button>
</div>
</div>
52 changes: 21 additions & 31 deletions src/preferences/PreferencesDialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,27 @@ define(function (require, exports, module) {
* of the clicked button when the dialog is dismissed. Never rejected.
*/
function showProjectPreferencesDialog(baseUrl, errorMessage) {
var $dlg,
$title,
$baseUrlControl,
var $baseUrlControl,
dialog;

dialog = Dialogs.showModalDialogUsingTemplate(Mustache.render(SettingsDialogTemplate, Strings));


// Title
var projectName = "",
projectRoot = ProjectManager.getProjectRoot(),
title;
if (projectRoot) {
projectName = projectRoot.name;
}
title = StringUtils.format(Strings.PROJECT_SETTINGS_TITLE, projectName);

var templateVars = {
title : title,
baseUrl : baseUrl,
errorMessage : errorMessage,
Strings : Strings
};

dialog = Dialogs.showModalDialogUsingTemplate(Mustache.render(SettingsDialogTemplate, templateVars));

dialog.done(function (id) {
if (id === Dialogs.DIALOG_BTN_OK) {
var baseUrlValue = $baseUrlControl.val();
Expand All @@ -100,32 +114,8 @@ define(function (require, exports, module) {
}
});

// Populate project settings
$dlg = dialog.getElement();

// Title
$title = $dlg.find(".dialog-title");
var projectName = "",
projectRoot = ProjectManager.getProjectRoot(),
title;
if (projectRoot) {
projectName = projectRoot.name;
}
title = StringUtils.format(Strings.PROJECT_SETTINGS_TITLE, projectName);
$title.text(title);

// Base URL
$baseUrlControl = $dlg.find(".url");
if (baseUrl) {
$baseUrlControl.val(baseUrl);
}

// Error message
if (errorMessage) {
$dlg.find(".field-container").append("<div class='alert' style='margin-bottom: 0'>" + errorMessage + "</div>");
}

// Give focus to first control
$baseUrlControl = dialog.getElement().find(".url");
$baseUrlControl.focus();

return dialog;
Expand Down