Commit d8b419c6 by muhammad-ammar

Review changes

parent 6134e8b5
/** /**
* Provides useful utilities for views. * Provides useful utilities for views.
*/ */
define(["jquery", "underscore", "gettext", "js/views/feedback_notification", "js/views/feedback_prompt"], ;(function (define) {
'use strict';
define(["jquery", "underscore", "gettext", "common/js/components/views/feedback_notification",
"common/js/components/views/feedback_prompt"],
function ($, _, gettext, NotificationView, PromptView) { function ($, _, gettext, NotificationView, PromptView) {
var toggleExpandCollapse, showLoadingIndicator, hideLoadingIndicator, confirmThenRunOperation, var toggleExpandCollapse, showLoadingIndicator, hideLoadingIndicator, confirmThenRunOperation,
runOperationShowingMessage, disableElementWhileRunning, getScrollOffset, setScrollOffset, runOperationShowingMessage, disableElementWhileRunning, getScrollOffset, setScrollOffset,
...@@ -246,3 +249,4 @@ define(["jquery", "underscore", "gettext", "js/views/feedback_notification", "js ...@@ -246,3 +249,4 @@ define(["jquery", "underscore", "gettext", "js/views/feedback_notification", "js
'checkTotalKeyLengthViolations': checkTotalKeyLengthViolations 'checkTotalKeyLengthViolations': checkTotalKeyLengthViolations
}; };
}); });
}).call(this, define || RequireJS.define);
define(["jquery", "underscore", "underscore.string", "backbone", "js/utils/templates"], ;(function (define) {
function($, _, str, Backbone, TemplateUtils) { 'use strict';
define(["jquery",
"underscore",
"underscore.string",
"backbone",
"text!common/templates/components/system-feedback.underscore"],
function($, _, str, Backbone, systemFeedbackTemplate) {
var SystemFeedback = Backbone.View.extend({ var SystemFeedback = Backbone.View.extend({
options: { options: {
title: "", title: "",
...@@ -50,7 +56,6 @@ define(["jquery", "underscore", "underscore.string", "backbone", "js/utils/templ ...@@ -50,7 +56,6 @@ define(["jquery", "underscore", "underscore.string", "backbone", "js/utils/templ
throw "SystemFeedback: intent required (given " + throw "SystemFeedback: intent required (given " +
JSON.stringify(this.options) + ")"; JSON.stringify(this.options) + ")";
} }
this.template = TemplateUtils.loadTemplate("system-feedback");
this.setElement($("#page-" + this.options.type)); this.setElement($("#page-" + this.options.type));
// handle single "secondary" action // handle single "secondary" action
if (this.options.actions && this.options.actions.secondary && if (this.options.actions && this.options.actions.secondary &&
...@@ -103,7 +108,7 @@ define(["jquery", "underscore", "underscore.string", "backbone", "js/utils/templ ...@@ -103,7 +108,7 @@ define(["jquery", "underscore", "underscore.string", "backbone", "js/utils/templ
singleton.stopListening(); singleton.stopListening();
singleton.undelegateEvents(); singleton.undelegateEvents();
} }
this.$el.html(this.template(this.options)); this.$el.html(_.template(systemFeedbackTemplate)(this.options));
SystemFeedback["active_" + this.options.type] = this; SystemFeedback["active_" + this.options.type] = this;
return this; return this;
}, },
...@@ -144,3 +149,4 @@ define(["jquery", "underscore", "underscore.string", "backbone", "js/utils/templ ...@@ -144,3 +149,4 @@ define(["jquery", "underscore", "underscore.string", "backbone", "js/utils/templ
}); });
return SystemFeedback; return SystemFeedback;
}); });
}).call(this, define || RequireJS.define);
define(["jquery", "underscore", "underscore.string", "js/views/feedback"], function($, _, str, SystemFeedbackView) { ;(function (define) {
'use strict';
define(["jquery", "underscore", "underscore.string", "common/js/components/views/feedback"],
function($, _, str, SystemFeedbackView) {
str = str || _.str;
var Alert = SystemFeedbackView.extend({ var Alert = SystemFeedbackView.extend({
options: $.extend({}, SystemFeedbackView.prototype.options, { options: $.extend({}, SystemFeedbackView.prototype.options, {
type: "alert" type: "alert"
...@@ -34,4 +38,5 @@ define(["jquery", "underscore", "underscore.string", "js/views/feedback"], funct ...@@ -34,4 +38,5 @@ define(["jquery", "underscore", "underscore.string", "js/views/feedback"], funct
}); });
return Alert; return Alert;
}); });
}).call(this, define || RequireJS.define);
define(["jquery", "underscore", "underscore.string", "js/views/feedback"], function($, _, str, SystemFeedbackView) { ;(function (define) {
'use strict';
define(["jquery", "underscore", "underscore.string", "common/js/components/views/feedback"],
function($, _, str, SystemFeedbackView) {
str = str || _.str;
var Notification = SystemFeedbackView.extend({ var Notification = SystemFeedbackView.extend({
options: $.extend({}, SystemFeedbackView.prototype.options, { options: $.extend({}, SystemFeedbackView.prototype.options, {
type: "notification", type: "notification",
...@@ -26,4 +30,5 @@ define(["jquery", "underscore", "underscore.string", "js/views/feedback"], funct ...@@ -26,4 +30,5 @@ define(["jquery", "underscore", "underscore.string", "js/views/feedback"], funct
miniOptions.closeIcon = false; miniOptions.closeIcon = false;
return Notification; return Notification;
}); });
}).call(this, define || RequireJS.define);
define(["jquery", "underscore", "underscore.string", "js/views/feedback"], function($, _, str, SystemFeedbackView) { ;(function (define) {
'use strict';
define(["jquery", "underscore", "underscore.string", "common/js/components/views/feedback"],
function($, _, str, SystemFeedbackView) {
str = str || _.str;
var Prompt = SystemFeedbackView.extend({ var Prompt = SystemFeedbackView.extend({
options: $.extend({}, SystemFeedbackView.prototype.options, { options: $.extend({}, SystemFeedbackView.prototype.options, {
type: "prompt", type: "prompt",
...@@ -32,4 +36,5 @@ define(["jquery", "underscore", "underscore.string", "js/views/feedback"], funct ...@@ -32,4 +36,5 @@ define(["jquery", "underscore", "underscore.string", "js/views/feedback"], funct
}); });
return Prompt; return Prompt;
}); });
}).call(this, define || RequireJS.define);
define(["jquery", "underscore", "js/views/baseview", "js/views/utils/view_utils", "js/spec_helpers/edit_helpers"], ;(function (define) {
function ($, _, BaseView, ViewUtils, ViewHelpers) { 'use strict';
define(["jquery", "underscore", "common/js/components/utils/view_utils", "common/js/spec_helpers/view_helpers", 'jasmine-stealth'],
function ($, _, ViewUtils, ViewHelpers) {
describe("ViewUtils", function() { describe("ViewUtils", function() {
describe("disabled element while running", function() { describe("disabled element while running", function() {
...@@ -90,3 +92,4 @@ define(["jquery", "underscore", "js/views/baseview", "js/views/utils/view_utils" ...@@ -90,3 +92,4 @@ define(["jquery", "underscore", "js/views/baseview", "js/views/utils/view_utils"
}); });
}); });
}); });
}).call(this, define || RequireJS.define);
\ No newline at end of file
/** /**
* Provides helper methods for invoking Studio modal windows in Jasmine tests. * Provides helper methods for invoking Studio modal windows in Jasmine tests.
*/ */
define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt", 'common/js/spec_helpers/ajax_helpers', ;(function (define) {
"common/js/spec_helpers/template_helpers"], 'use strict';
function($, NotificationView, Prompt, AjaxHelpers, TemplateHelpers) { define(["jquery", "common/js/components/views/feedback_notification", "common/js/components/views/feedback_prompt",
'common/js/spec_helpers/ajax_helpers'],
function($, NotificationView, Prompt, AjaxHelpers) {
var installViewTemplates, createFeedbackSpy, verifyFeedbackShowing, var installViewTemplates, createFeedbackSpy, verifyFeedbackShowing,
verifyFeedbackHidden, createNotificationSpy, verifyNotificationShowing, verifyFeedbackHidden, createNotificationSpy, verifyNotificationShowing,
verifyNotificationHidden, createPromptSpy, confirmPrompt, inlineEdit, verifyInlineEditChange, verifyNotificationHidden, createPromptSpy, confirmPrompt, inlineEdit, verifyInlineEditChange,
installMockAnalytics, removeMockAnalytics, verifyPromptShowing, verifyPromptHidden; installMockAnalytics, removeMockAnalytics, verifyPromptShowing, verifyPromptHidden,
clickDeleteItem, patchAndVerifyRequest, submitAndVerifyFormSuccess, submitAndVerifyFormError;
installViewTemplates = function(append) { installViewTemplates = function() {
TemplateHelpers.installTemplate('system-feedback', !append);
appendSetFixtures('<div id="page-notification"></div>'); appendSetFixtures('<div id="page-notification"></div>');
}; };
...@@ -144,3 +146,4 @@ define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt", ...@@ -144,3 +146,4 @@ define(["jquery", "js/views/feedback_notification", "js/views/feedback_prompt",
'submitAndVerifyFormError': submitAndVerifyFormError 'submitAndVerifyFormError': submitAndVerifyFormError
}; };
}); });
}).call(this, define || RequireJS.define);
...@@ -21,17 +21,16 @@ ...@@ -21,17 +21,16 @@
<% if(obj.actions) { %> <% if(obj.actions) { %>
<nav class="nav-actions"> <nav class="nav-actions">
<h3 class="sr"><%= type %> Actions</h3>
<ul> <ul>
<% if(actions.primary) { %> <% if(actions.primary) { %>
<li class="nav-item"> <li class="nav-item">
<a href="#" class="button action-primary <%= actions.primary.class %>"><%= actions.primary.text %></a> <button class="action-primary <%= actions.primary.class %>"><%= actions.primary.text %></button>
</li> </li>
<% } %> <% } %>
<% if(actions.secondary) { <% if(actions.secondary) {
_.each(actions.secondary, function(secondary) { %> _.each(actions.secondary, function(secondary) { %>
<li class="nav-item"> <li class="nav-item">
<a href="#" class="button action-secondary <%= secondary.class %>"><%= secondary.text %></a> <button class="action-secondary <%= secondary.class %>"><%= secondary.text %></button>
</li> </li>
<% }); <% });
} %> } %>
......
...@@ -74,13 +74,13 @@ define([ ...@@ -74,13 +74,13 @@ define([
return profileView; return profileView;
}; };
clickLeaveTeam = function(requests, view, confirmLeave) { clickLeaveTeam = function(requests, view, options) {
expect(view.$(leaveTeamLinkSelector).length).toBe(1); expect(view.$(leaveTeamLinkSelector).length).toBe(1);
// click on Leave Team link under Team Details // click on Leave Team link under Team Details
view.$(leaveTeamLinkSelector).click(); view.$(leaveTeamLinkSelector).click();
if (confirmLeave) { if (!options.cancel) {
// click on Confirm button on dialog // click on Confirm button on dialog
$('.prompt.warning .action-primary').click(); $('.prompt.warning .action-primary').click();
...@@ -121,7 +121,7 @@ define([ ...@@ -121,7 +121,7 @@ define([
view = createTeamProfileView(requests, {membership: DEFAULT_MEMBERSHIP}); view = createTeamProfileView(requests, {membership: DEFAULT_MEMBERSHIP});
expect(view.$('.new-post-btn').length).toEqual(1); expect(view.$('.new-post-btn').length).toEqual(1);
clickLeaveTeam(requests, view, true); clickLeaveTeam(requests, view, {cancel: false});
expect(view.$('.new-post-btn').length).toEqual(0); expect(view.$('.new-post-btn').length).toEqual(0);
}); });
}); });
...@@ -188,7 +188,7 @@ define([ ...@@ -188,7 +188,7 @@ define([
requests, {country: 'US', language: 'en', membership: DEFAULT_MEMBERSHIP} requests, {country: 'US', language: 'en', membership: DEFAULT_MEMBERSHIP}
); );
assertTeamDetails(view, 1, true); assertTeamDetails(view, 1, true);
clickLeaveTeam(requests, view, true); clickLeaveTeam(requests, view, {cancel: false});
assertTeamDetails(view, 0, false); assertTeamDetails(view, 0, false);
}); });
...@@ -199,7 +199,7 @@ define([ ...@@ -199,7 +199,7 @@ define([
requests, {country: 'US', language: 'en', membership: DEFAULT_MEMBERSHIP} requests, {country: 'US', language: 'en', membership: DEFAULT_MEMBERSHIP}
); );
assertTeamDetails(view, 1, true); assertTeamDetails(view, 1, true);
clickLeaveTeam(requests, view, false); clickLeaveTeam(requests, view, {cancel: true});
assertTeamDetails(view, 1, true); assertTeamDetails(view, 1, true);
}); });
......
../../../common/static/sass/_mixins-inherited.scss
\ No newline at end of file
../../../common/static/sass/_mixins.scss
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment