-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability for admins to copy rules from one user to another
- Loading branch information
Showing
10 changed files
with
265 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"anyOf": [ | ||
{ | ||
"$ref": "roles#/definitions/admin" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<form class="form-horizontal"> | ||
<div class="modal-header text-left"> | ||
<h4 class="modal-title">Copy Rules to <%- name %></h4> | ||
</div> | ||
<div class="modal-body"> | ||
<p>This procedure will copy <strong>ALL</strong> of the defined rules from the selected user below in to <%- name %>'s account.</p> | ||
<p>This will NOT overwrite or remove any existing rules for the user, who currently has <strong><%- rule_count %></strong> rules.</p> | ||
|
||
<div class="form-group"> | ||
<label class="col-sm-3 control-label">Copy rules from</label> | ||
<div class="col-sm-9"> | ||
<select name="from_user_id" class="form-control" required> | ||
<option value="">Select...</option> | ||
<% | ||
var users = getUsers(); | ||
_.each(users, function (user) { | ||
if (user.id !== id && user.rule_count > 0) { | ||
%> | ||
<option value="<%- user.id %>"><%- user.name %> (<%- user.rule_count %> rules)</option> | ||
<% | ||
} | ||
}); | ||
%> | ||
</select> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> | ||
<button type="submit" class="btn btn-accent save">Copy</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
import Mn from 'backbone.marionette'; | ||
|
||
const template = require('./copy_rules.ejs'); | ||
const Controller = require('../controller'); | ||
const Api = require('../api'); | ||
const App = require('../main'); | ||
|
||
module.exports = Mn.View.extend({ | ||
template: template, | ||
|
||
ui: { | ||
form: 'form', | ||
buttons: 'form button', | ||
cancel: 'button.cancel', | ||
from_user_id: 'select[name="from_user_id"]' | ||
}, | ||
|
||
events: { | ||
'submit @ui.form': function (e) { | ||
e.preventDefault(); | ||
let from_user_id = parseInt(this.ui.from_user_id.val(), 10); | ||
|
||
this.ui.buttons.prop('disabled', true).addClass('btn-disabled'); | ||
Api.Rules.copy(from_user_id, this.model.get('id')) | ||
.then(() => { | ||
App.UI.closeModal(); | ||
Controller.showUsers(); | ||
}) | ||
.catch(err => { | ||
alert(err.message); | ||
this.ui.buttons.prop('disabled', false).removeClass('btn-disabled'); | ||
}); | ||
} | ||
}, | ||
|
||
templateContext: function () { | ||
let view = this; | ||
|
||
return { | ||
getUsers: function () { | ||
return view.getOption('users'); | ||
} | ||
}; | ||
} | ||
}); |
Oops, something went wrong.