partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

TipOfTheDayConfiguration.js (1698B)


      1 Ext.define('PartKeepr.Components.UserPreferences.Preferences.TipOfTheDayConfiguration', {
      2     extend: 'PartKeepr.Components.Preferences.PreferenceEditor',
      3 
      4     initComponent: function ()
      5     {
      6         this.displayTipsOnLoginCheckbox = Ext.create("Ext.form.field.Checkbox", {
      7             boxLabel: i18n("Display tips on login")
      8         });
      9 
     10         if (PartKeepr.getApplication().getUserPreference("partkeepr.tipoftheday.showtips") === false) {
     11             this.displayTipsOnLoginCheckbox.setValue(false);
     12         } else {
     13             this.displayTipsOnLoginCheckbox.setValue(true);
     14         }
     15 
     16 
     17         this.resetTipsButton = Ext.create("Ext.button.Button", {
     18             text: i18n("Mark all tips unread"),
     19             handler: this.onMarkAllTipsUnreadClick,
     20             scope: this
     21         });
     22 
     23         this.items = [
     24             this.displayTipsOnLoginCheckbox,
     25             this.resetTipsButton
     26         ];
     27 
     28         this.callParent();
     29     },
     30     /**
     31      * Marks all tips as unread
     32      */
     33     onMarkAllTipsUnreadClick: function ()
     34     {
     35         PartKeepr.TipOfTheDayBundle.Entity.TipOfTheDay.callPostCollectionAction("markAllTipsAsUnread", {}, function ()
     36             {
     37                 var msg = i18n("All tips have been marked as unread");
     38                 Ext.Msg.alert(msg, msg);
     39             }
     40         );
     41     },
     42     onSave: function ()
     43     {
     44         PartKeepr.getApplication().setUserPreference("partkeepr.tipoftheday.showtips",
     45             this.displayTipsOnLoginCheckbox.getValue());
     46     },
     47     statics: {
     48         iconCls: 'fugue-icon light-bulb',
     49         title: i18n('Tip of the Day'),
     50         menuPath: [{iconCls: 'fugue-icon ui-scroll-pane-image', text: i18n("User Interface")}]
     51     }
     52 });