-
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 3 commits
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) { | |
| * 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 = $.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. |
||
|
|
||
| dialog = Dialogs.showModalDialogUsingTemplate(Mustache.render(SettingsDialogTemplate, templateVars)); | ||
|
|
||
| dialog.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 = 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; | ||
|
|
||
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.
Interesting technique for hiding elements in a Template!