-
-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
identities delete icon #1013
Comments
specific identity of particular domain i dont want to allow to delete it? |
Currently this is not possible. |
Here's an example class MyIdentitiesPlugin extends \RainLoop\Plugins\AbstractPlugin
{
public function Init() : void
{
$this->addHook("json.before-IdentityDelete", 'beforeIdentityDelete')
$this->addHook("json.after-AccountsAndIdentities", 'afterAccountsAndIdentities')
}
public function beforeIdentityDelete()
{
$sId = \trim($this->Manager()->Actions()->GetActionParam('idToDelete', ''));
if ('NotAllowed' = $sId) {
// Throw exception
}
}
public function afterAccountsAndIdentities(array &$aResponse)
{
// find identity in $aResponse['Identities']
// if not found, add the RainLoop\Model\Identity
}
} |
I dont want to a delete button in some of the domains identities but above code only allow to stop it while deleting |
I've added a change so you can solve this with CSS. [data-identity-id="0123456"] .delete {
display: none;
} Where If you need a more complex solution, this is possible with JavaScript. addEventListener('rl-view-model.create', event => {
if ('SettingsAccounts' === e.detail.viewModelTemplateID) {
// https://github.com/the-djmaze/snappymail/blob/master/dev/Settings/User/Accounts.js
let view = e.detail;
// https://knockoutjs.com/documentation/observableArrays.html
// view.identities.subscribe(fn, thisArg, "arrayChange");
view.canDelete = ko.computed(identity =>
!identity.askDelete() && identity.id() && !identity.email().includes('@domain')
);
}
});
let template = document.getElementById('SettingsAccounts');
const deleteBtn = template.content.querySelector('.identities-list .delete');
if (deleteBtn) {
deleteBtn.dataset.bind.replace('!askDelete() && id()', 'function(){$root.canDelete($data)}');
} |
@the-djmaze the above code does not work. |
In settings->accounts,
i have multiple identities but i wanted to stop user from deleting the specific identity . Is there any way to do so?
The text was updated successfully, but these errors were encountered: