From f33056102509c1d27e4790dc9ee81dfb1e84410a Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 28 Mar 2015 15:43:52 +1030 Subject: [PATCH] Disable notification type/method combinations that are not available --- .../core/ember/app/components/ui/yesno-input.js | 1 + .../app/components/user/notification-grid.js | 3 ++- .../core/ember/app/styles/flarum/settings.less | 15 +++++++++++---- .../components/user/notification-grid.hbs | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/framework/core/ember/app/components/ui/yesno-input.js b/framework/core/ember/app/components/ui/yesno-input.js index 915254259..88e16897c 100644 --- a/framework/core/ember/app/components/ui/yesno-input.js +++ b/framework/core/ember/app/components/ui/yesno-input.js @@ -9,6 +9,7 @@ export default Ember.Component.extend({ classNames: ['yesno-control'], toggleState: true, + disabled: false, didInsertElement: function() { var component = this; diff --git a/framework/core/ember/app/components/user/notification-grid.js b/framework/core/ember/app/components/user/notification-grid.js index 2041f4448..66a6d68bb 100644 --- a/framework/core/ember/app/components/user/notification-grid.js +++ b/framework/core/ember/app/components/user/notification-grid.js @@ -43,7 +43,8 @@ export default Ember.Component.extend({ type: type, method: method, enabled: !!user.get(preferenceKey), - loading: false + loading: false, + disabled: typeof user.get(preferenceKey) == 'undefined' }); cell.set('save', function(value, component) { cell.set('loading', true); diff --git a/framework/core/ember/app/styles/flarum/settings.less b/framework/core/ember/app/styles/flarum/settings.less index 4baf77948..f89323e69 100644 --- a/framework/core/ember/app/styles/flarum/settings.less +++ b/framework/core/ember/app/styles/flarum/settings.less @@ -31,7 +31,7 @@ border-bottom: 1px solid @fl-body-bg; color: @fl-body-control-color; } - & td, & th, & .yesno-cell .yesno { + & td, & th, & .yesno { padding: 10px 15px; } & thead { @@ -47,12 +47,19 @@ } } & .yesno-cell { + padding: 0; + } + & .yesno-control { + display: block; + } + & .yesno { text-align: center; cursor: pointer; - padding: 0; - &:hover, &.highlighted { - background: darken(@fl-body-control-bg, 4%); + &:not(.disabled) { + &:hover, &.highlighted { + background: darken(@fl-body-control-bg, 4%); + } } } & .toggle-group { diff --git a/framework/core/ember/app/templates/components/user/notification-grid.hbs b/framework/core/ember/app/templates/components/user/notification-grid.hbs index 72b4f2056..88d5e6319 100644 --- a/framework/core/ember/app/templates/components/user/notification-grid.hbs +++ b/framework/core/ember/app/templates/components/user/notification-grid.hbs @@ -12,7 +12,7 @@ {{row.label}} {{#each row.cells as |cell|}} - {{ui/yesno-input toggleState=cell.enabled changed=cell.save loading=cell.loading}} + {{ui/yesno-input toggleState=cell.enabled changed=cell.save loading=cell.loading disabled=cell.disabled}} {{/each}} {{/each}}