Is it possible to make Sugar Dashboard Uneditable for Regular Users?
Is it possible to make Sugar Dashboard Uneditable for Regular Users?
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]);
}
}
})
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?
Hi
Where you put the customization file?
this file should be in custom/clients/base/views/dashboard-headerpane/
and remember execute a quick repair
regards
In your previous reply you said that this is correct file
You need to create a new file in custom/clients/base/views/dashboard-headerpane.js
but now I see that it is
custom/clients/base/views/dashboard-headerpane/
so do you mean custom/clients/base/views/dashboard-headerpane/dashboard-headerpane.js or custom/clients/base/views/dashboard-headerpane.js ?
Sorry, put the file in custom/clients/base/views/dashboard-headerpane/dashboard-headerpane.js
regards
THANK YOU VERY MUCH!!!!!
What can I do for hide create button too??
Hi Nick Gamora
you can play with the metadata to hide any button
In your custom code use a debugger to stop the execution and then open the developer tools of chrome to see the buttons metadata
e.g.
initialize: function(options) {
this._super("initialize", [options]);
// validate user
if( app.user.get('type')!= "admin" && this.module=="Home"){
debugger; // this debugger stops the execution
this.meta.buttons[0].buttons = _.filter(this.meta.buttons[0].buttons, function(obj){ return obj.name != 'edit_button'; });
}
},
in the console of chrome execute:
this.meta.buttons
this instruction will display the metadata of buttons now you need add a line in your code to hide the button that you want similar to:
this.meta.buttons = _.filter(this.meta.buttons, function(obj){ return obj.name != '<buttonName>'; });
Regards
Thank you, Cesar!
I made this row
this.meta.buttons[0].buttons = _.filter(this.meta.buttons[0].buttons, function(obj){ return obj.name!='edit_button' && obj.name!='add_button'; });
and button is hide!!