Skip to content
This repository has been archived by the owner on Aug 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #147 from SlateFoundation/develop
Browse files Browse the repository at this point in the history
Release: slate-admin v2.2.4
  • Loading branch information
themightychris authored Sep 13, 2017
2 parents fc073e2 + 58be4ee commit 627902d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
38 changes: 38 additions & 0 deletions sencha-workspace/SlateAdmin/app/controller/people/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Ext.define('SlateAdmin.controller.people.Profile', {
extend: 'Ext.app.Controller',
requires: [
'Ext.DomHelper',
'Ext.window.MessageBox',

/* global Slate */
Expand Down Expand Up @@ -32,6 +33,8 @@ Ext.define('SlateAdmin.controller.people.Profile', {
temporaryPasswordFieldCt: 'people-details-profile fieldcontainer#temporaryPasswordFieldCt',
temporaryPasswordField: 'people-details-profile field[name=TemporaryPassword]',
resetTemporaryPasswordBtn: 'people-details-profile button[action=reset-temporary-password]',
masqueradeBtnCt: 'people-details-profile fieldcontainer#masqueradeBtnCt',
masqueradeBtn: 'people-details-profile button[action=masquerade]',
groupsField: 'people-details-profile field[name=groupIDs]',
manager: 'people-manager'
},
Expand All @@ -58,6 +61,9 @@ Ext.define('SlateAdmin.controller.people.Profile', {
},
resetTemporaryPasswordBtn: {
click: 'onResetTemporaryPasswordClick'
},
masqueradeBtn: {
click: 'onMasqueradeClick'
}
},

Expand Down Expand Up @@ -91,6 +97,7 @@ Ext.define('SlateAdmin.controller.people.Profile', {

me.getTemporaryPasswordFieldCt().setVisible(siteUserIsAdmin);
me.getUsernameField().setReadOnly(!siteUserIsAdmin);
me.getMasqueradeBtnCt().setVisible(siteUserIsAdmin && person.get('Username'));

// ensure groups store is loaded before loading record because boxselect doesn't hande re-setting unknown values after local store load
if (groupsStore.isLoaded()) {
Expand Down Expand Up @@ -248,6 +255,37 @@ Ext.define('SlateAdmin.controller.people.Profile', {
);
},

onMasqueradeClick: function(masqueradeBtn) {
var person = this.getProfileForm().getRecord();

Ext.Msg.confirm(
'Log in as user '+person.get('Username'),
'<p>Masquerading will switch you into this user&rsquo;s account, as if you had logged in as them. You will be logged out of your administrator session, and will need to manually log out of the user account and back into your administrator account to return. Consider doing this from an incognito browser window if you would like to maintain an administrative session in your normal browser window while masquerading as other users.</p><p>Clicking continue will immediately leave this screen and take you to the user&rsquo;s dashboard.</p>',
function(btnId) {
if (btnId != 'yes') {
return;
}

masqueradeBtn.disable();

Ext.DomHelper.append(Ext.getBody(), {
tag: 'form',
action: Slate.API.buildUrl('/masquerade'),
method: 'POST',
style: {
display: 'none'
},
cn: [{
tag: 'input',
type: 'hidden',
name: 'username',
value: person.get('Username')
}]
}).submit();
}
);
},

// internal methods

/**
Expand Down
18 changes: 18 additions & 0 deletions sencha-workspace/SlateAdmin/app/view/people/details/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Ext.define('SlateAdmin.view.people.details.Profile', {
'Ext.form.FieldSet',
'Ext.form.FieldContainer',
'Ext.form.field.Tag',
'Ext.form.field.Number',
'SlateAdmin.proxy.Records',
'SlateAdmin.model.person.Group'
],
Expand Down Expand Up @@ -103,6 +104,17 @@ Ext.define('SlateAdmin.view.people.details.Profile', {
text: 'Reissue',
glyph: 0xf084 // fa-key
}]
},{
xtype: 'fieldcontainer',
itemId: 'masqueradeBtnCt',
fieldLabel: 'Masquerading',
hidden: true,
items: [{
xtype: 'button',
action: 'masquerade',
text: 'Log in as this user',
glyph: 0xf090 // fa-sign-in
}]
}]
},{
xtype: 'fieldset',
Expand Down Expand Up @@ -142,6 +154,12 @@ Ext.define('SlateAdmin.view.people.details.Profile', {
name: 'StudentNumber',
fieldLabel: 'Student #',
hidden: true
},{
xtype: 'numberfield',
name: 'GraduationYear',
fieldLabel: 'Graduation Year',
minValue: 1990,
hidden: true
},{
xtype: 'tagfield',
name: 'groupIDs',
Expand Down

0 comments on commit 627902d

Please sign in to comment.