Is it possible to make Sugar Dashboard Uneditable for Regular Users?

 Is it possible to make Sugar Dashboard Uneditable for Regular Users?

Parents
  • Hi Nick Gamora

    yes it is possible, you need to customize the dashboard-headerpane view;
    e.g.
    If you want remove the edit button from metadata you should customize the initialize function to overwrite the buttons
    Like this:

    ....

    initialize: function(options) {

       this._super("initialize", [options]);

       // validate user

       if( app.user.get('type') != "admin" ){

          this.meta.buttons[0].buttons = _.filter(this.meta.buttons[0].buttons, function(obj){ return obj.name != 'edit_button'; });

      } 

    }

    ...

    Or if you need to show the buttons and prevent the edit action you need to customize the editClicked function.

    e.g.

    editClicked: function(evt) {

       // validate user

       if( app.user.get('type') != "admin" ){

          // here you can show an alert 

          app.alert.show('message-id', {
             level: 'error',
             title: 'You aren't admin'
          });

      } 

      else{

        this._super("editClicked", [evt]);

      }

    }

  • Thank You for the answer, I'm new to working with Sugar 7 dashlet, can you tell which file it is necessary to register?

  • You need to create a new file in custom/clients/base/views/dashboard-headerpane.js and put the code after that you need repair the instance: https://support.sugarcrm.com/Knowledge_Base/Troubleshooting/Running_Quick_Repair_and_Rebuild/index.html 

  • I`m sorry, but I does not see any changes or differens in the My Dashbord or My Legasy Dashbord in both cases(Regular User or Administrator). I user Repair, I use developer mode (or not developer, no difference what), but I does not understand what it is not working.
    ({
        editClicked: function(evt) {
            // validate user    
            if( app.user.get('type') != "admin" ){
     
                // here you can show an alert
                app.alert.show('message-id', {
                    level: 'error',
                    title: "You aren't admin"
                });

            } else{
            this._super("editClicked", [evt]);
          }
        }
    })

  • Hi

    you need to extend the view

    ({
       extendsFrom:'DashboardHeaderpaneView',
       editClicked: function(evt) {
          // validate user
          if( app.user.get('type') != "admin" ){
             // here you can show an alert
             app.alert.show('message-id', {
                level: 'error',
                title: "You aren't admin"
             });
          } else{
             this._super("editClicked", [evt]);
          }
       }
    })

    It's possible that you need validate the current module 

    ...

    if( app.user.get('type') != "admin"  and this.module=="Home")

    ...

  • Try use your code:
    ({
        extendsFrom:'DashboardHeaderpaneView',    

        initialize: function(options) {
            this._super("initialize", [options]);
           // validate user
             if( app.user.get('type')!= "admin" && this.module=="Home"){
                  this.meta.buttons[0].buttons = _.filter(this.meta.buttons[0].buttons, function(obj){ return obj.name != 'edit_button'; });
            }
          },
        
        editClicked: function(evt) {
            // validate user    
            if( app.user.get('type')!="admin" && this.module=="Home"){
     
                // here you can show an alert
                app.alert.show('message-id', {
                    level: 'error',
                    title: "You aren't admin"
                });

            } else{
            this._super("editClicked", [evt]);
          }
        }
    })

    but do not see anything changes after rapair and rebuilt. What I do wrong?

Reply
  • Try use your code:
    ({
        extendsFrom:'DashboardHeaderpaneView',    

        initialize: function(options) {
            this._super("initialize", [options]);
           // validate user
             if( app.user.get('type')!= "admin" && this.module=="Home"){
                  this.meta.buttons[0].buttons = _.filter(this.meta.buttons[0].buttons, function(obj){ return obj.name != 'edit_button'; });
            }
          },
        
        editClicked: function(evt) {
            // validate user    
            if( app.user.get('type')!="admin" && this.module=="Home"){
     
                // here you can show an alert
                app.alert.show('message-id', {
                    level: 'error',
                    title: "You aren't admin"
                });

            } else{
            this._super("editClicked", [evt]);
          }
        }
    })

    but do not see anything changes after rapair and rebuilt. What I do wrong?

Children