-
Notifications
You must be signed in to change notification settings - Fork 7.6k
[OPEN] Move the Project Preferences Dialog variables to the template #3286
Changes from 1 commit
d5ea90b
231d0db
be5e767
79bbd1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,13 +80,26 @@ define(function (require, exports, module) { | |
| * project settings and clicks OK, or rejected if user clicks Cancel. | ||
| */ | ||
| function showProjectPreferencesDialog(baseUrl, errorMessage) { | ||
|
|
||
| var $dlg, | ||
| $title, | ||
| $baseUrlControl, | ||
| var $baseUrlControl, | ||
| promise; | ||
|
|
||
| promise = 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 = $.extend({ | ||
| title : title, | ||
| baseUrl : baseUrl, | ||
| errorMessage : errorMessage | ||
| }, Strings); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Strings Object is big (and getting bigger all of the time), so I am wondering if we should avoid copying the entire Strings Object here for only 4 strings. Maybe this would be better: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another trick I've used in similar situations is just to include
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer @njx idea of passing the object and using the dot notation to make the template easier to expand later, since you don't need to keep adding the new strings to it. |
||
| console.log(templateVars, Mustache.render(SettingsDialogTemplate, templateVars)); | ||
|
|
||
| promise = Dialogs.showModalDialogUsingTemplate(Mustache.render(SettingsDialogTemplate, templateVars)) | ||
| .done(function (id) { | ||
| if (id === Dialogs.DIALOG_BTN_OK) { | ||
| var baseUrlValue = $baseUrlControl.val(); | ||
|
|
@@ -100,32 +113,8 @@ define(function (require, exports, module) { | |
| } | ||
| }); | ||
|
|
||
| // Populate project settings | ||
| $dlg = $(".project-settings-dialog.instance"); | ||
|
|
||
| // 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-message' style='margin-bottom: 0'>" + errorMessage + "</div>"); | ||
| } | ||
|
|
||
| // Give focus to first control | ||
| $baseUrlControl = $(".project-settings-dialog.instance").find(".url"); | ||
| $baseUrlControl.focus(); | ||
|
|
||
| return promise; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does
{{{errorMessage}}}have triple (not double) curly braces?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember right, I think that previously the error message string was using
—for the dash which required the 3 curly braces to display it correctly, but now it doesn't use it, so replaced them with 2.