diff --git a/app/coffeescripts/models/PublishableModuleItem.coffee b/app/coffeescripts/models/PublishableModuleItem.coffee index 8acef9cad9e..48129921484 100644 --- a/app/coffeescripts/models/PublishableModuleItem.coffee +++ b/app/coffeescripts/models/PublishableModuleItem.coffee @@ -16,6 +16,7 @@ define [ published: true publishable: true unpublishable: true + module_item_name: null branch: (key) -> (@[key][@get('module_type')] or @[key].generic).call(this) @@ -45,10 +46,24 @@ define [ module: -> module: @attributes disabledMessages: - generic: -> I18n.t('disabled', 'Publishing is disabled for this item') - assignment: -> I18n.t('disabled_assignment', "Can't unpublish if there are student submissions") - quiz: -> I18n.t('disabled_quiz', "Can't unpublish if there are student submissions") - discussion_topic: -> I18n.t('disabled_discussion_topic', "Can't unpublish if there are student submissions") + generic: -> if @get('module_item_name') + I18n.t('Publishing %{item_name} is disabled', {item_name: @get('module_item_name')}) + else + I18n.t('Publishing is disabled for this item') + + assignment: -> if @get('module_item_name') + I18n.t("Can't unpublish %{item_name} if there are student submissions", {item_name: @get('module_item_name')}) + else + I18n.t("Can't unpublish if there are student submissions") + + quiz: -> if @get('module_item_name') + I18n.t("Can't unpublish %{item_name} if there are student submissions", {item_name: @get('module_item_name')}) + else + I18n.t("Can't unpublish if there are student submissions") + discussion_topic: -> if @get('module_item_name') + I18n.t("Can't unpublish %{item_name} if there are student submissions", {item_name: @get('module_item_name')}) + else + I18n.t("Can't unpublish if there are student submissions") publish: -> @save 'published', yes diff --git a/app/coffeescripts/react_files/components/PublishCloud.coffee b/app/coffeescripts/react_files/components/PublishCloud.coffee index 84507f77991..24a2a2502b8 100644 --- a/app/coffeescripts/react_files/components/PublishCloud.coffee +++ b/app/coffeescripts/react_files/components/PublishCloud.coffee @@ -16,6 +16,7 @@ define [ togglePublishClassOn: React.PropTypes.object model: customPropTypes.filesystemObject userCanManageFilesForContext: React.PropTypes.bool.isRequired + fileName: React.PropTypes.string # == React Functions == # getInitialState: -> @extractStateFromModel( @props.model ) diff --git a/app/coffeescripts/views/PublishButtonView.coffee b/app/coffeescripts/views/PublishButtonView.coffee index 4a25ef9e8c5..e4d60237663 100644 --- a/app/coffeescripts/views/PublishButtonView.coffee +++ b/app/coffeescripts/views/PublishButtonView.coffee @@ -13,6 +13,10 @@ define [ publishedClass: 'btn-published' unpublishClass: 'btn-unpublish' + # These values allow the default text to be overridden if necessary + @optionProperty 'publishText' + @optionProperty 'unpublishText' + tagName: 'button' className: 'btn' @@ -55,7 +59,7 @@ define [ addAriaLabel: (label) -> $label = @$el.find('span.screenreader-only.accessible_label') - $('').appendTo(@$el) unless $label.length + $label = $('').appendTo(@$el) unless $label.length $label.text label @$el.attr 'aria-label', label @@ -134,14 +138,14 @@ define [ renderPublish: -> @renderState text: I18n.t 'buttons.publish', 'Publish' - label: I18n.t 'buttons.publish_desc', 'Unpublished. Click to publish.' + label: @publishText || I18n.t 'Unpublished. Click to publish.' buttonClass: @publishClass iconClass: 'icon-unpublish' renderPublished: -> @renderState text: I18n.t 'buttons.published', 'Published' - label: I18n.t 'buttons.published_desc', 'Published. Click to unpublish.' + label: @unpublishText || I18n.t 'Published. Click to unpublish.' buttonClass: @publishedClass iconClass: 'icon-publish' diff --git a/app/coffeescripts/views/PublishIconView.coffee b/app/coffeescripts/views/PublishIconView.coffee index 395c6ebeda6..73bd08c5e1d 100644 --- a/app/coffeescripts/views/PublishIconView.coffee +++ b/app/coffeescripts/views/PublishIconView.coffee @@ -11,7 +11,12 @@ define [ tagName: 'span' className: 'publish-icon' + # These values allow the default text to be overridden if necessary + @optionProperty 'publishText' + @optionProperty 'unpublishText' + initialize: -> + super @events = _.extend({}, PublishButtonView.prototype.events, @events) events: {'keyclick' : 'click'} diff --git a/app/jsx/shared/PublishCloud.jsx b/app/jsx/shared/PublishCloud.jsx index 56934a175a1..7adf73446e6 100644 --- a/app/jsx/shared/PublishCloud.jsx +++ b/app/jsx/shared/PublishCloud.jsx @@ -30,6 +30,7 @@ define([ }; PublishCloud.render = function () { + var fileName = this.props.fileName || I18n.t('This file'); if (this.props.userCanManageFilesForContext) { if (this.state.published && this.state.restricted) { return ( @@ -40,7 +41,7 @@ define([ ref='publishCloud' className='btn-link published-status restricted' title={this.getRestrictedText()} - aria-label={this.getRestrictedText() + ' - ' + I18n.t('Click to modify')} + aria-label={`${fileName} is ${this.getRestrictedText()} - ${I18n.t('Click to modify')}`} > @@ -54,7 +55,7 @@ define([ ref='publishCloud' className='btn-link published-status hiddenState' title={I18n.t('Hidden. Available with a link')} - aria-label={I18n.t('Hidden. Available with a link - Click to modify')} + aria-label={`${fileName} is ${I18n.t('Hidden. Available with a link - Click to modify')}`} > @@ -68,7 +69,7 @@ define([ ref='publishCloud' className='btn-link published-status published' title={I18n.t('Published')} - aria-label={I18n.t('Published - Click to modify')} + aria-label={`${fileName} is ${I18n.t('Published - Click to modify')}`} > @@ -82,7 +83,7 @@ define([ ref='publishCloud' className='btn-link published-status unpublished' title={I18n.t('Unpublished')} - aria-label={I18n.t('Unpublished - Click to modify')} + aria-label={`${fileName} is ${I18n.t('Unpublished - Click to modify')}`} > @@ -97,7 +98,7 @@ define([ ref='publishCloud' className='published-status restricted' title={this.getRestrictedText()} - aria-label={this.getRestrictedText()} + aria-label={`${fileName} is ${this.getRestrictedText()}`} > diff --git a/app/views/context_modules/_context_module_next.html.erb b/app/views/context_modules/_context_module_next.html.erb index 063b51d42b8..77d406121ba 100644 --- a/app/views/context_modules/_context_module_next.html.erb +++ b/app/views/context_modules/_context_module_next.html.erb @@ -115,6 +115,8 @@ data-course-id="<%= context_module && context_module.context_id %>" data-published="<%= published_status == 'published' %>" data-publishable="<%= true %>" + data-publish-message="<%= t('Unpublished. Click to publish %{module_name}.', {module_name: context_module ? context_module.name : 'module'}) %>" + data-unpublish-message="<%= t('Published. Click to unpublish %{module_name}.', {module_name: context_module ? context_module.name : 'module'}) %>" title="" data-tooltip class="publish-icon module <%= published_status %>" @@ -123,10 +125,10 @@ - +