Ivan - Fix some staff edition issues [skip ci]
This commit is contained in:
parent
3a56a5410e
commit
2189c18a3c
|
@ -46,9 +46,11 @@ class TicketEvent extends React.Component {
|
|||
}
|
||||
|
||||
renderStaffPic() {
|
||||
let profilePicName = this.props.author.profilePic;
|
||||
|
||||
return (
|
||||
<div className="ticket-event__staff-pic">
|
||||
<img src={this.props.author.profilePic} className="ticket-event__staff-pic-img" />
|
||||
<img src={(profilePicName) ? API.getFileLink(profilePicName) : (API.getURL() + '/images/profile.png')} className="ticket-event__staff-pic-img" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class AdminPanelStaffWidget extends React.Component {
|
|||
</div>
|
||||
</div>
|
||||
<div className="admin-panel-staff-widget__profile-pic-wrapper">
|
||||
<img className="admin-panel-staff-widget__profile-pic" src={(this.props.session.userProfilePic) ? API.getFileLink(this.props.session.userProfilePic) : (API.getURL() + '/images/logo.png')} />
|
||||
<img className="admin-panel-staff-widget__profile-pic" src={(this.props.session.userProfilePic) ? API.getFileLink(this.props.session.userProfilePic) : (API.getURL() + '/images/profile.png')} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -167,7 +167,7 @@ class AdminPanelSystemPreferences extends React.Component {
|
|||
'recaptcha-private': form.reCaptchaPrivate,
|
||||
'url': form['url'],
|
||||
'title': form['title'],
|
||||
'layout': form['layout'] == 1 ? 'Full width' : 'Boxed',
|
||||
'layout': form['layout'] ? 'full-width' : 'boxed',
|
||||
'time-zone': form['time-zone'],
|
||||
'no-reply-email': form['no-reply-email'],
|
||||
'smtp-host': form['smtp-host'],
|
||||
|
|
|
@ -17,6 +17,10 @@ class AddStaffModal extends React.Component {
|
|||
closeModal: React.PropTypes.func
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
onSuccess: React.PropTypes.func
|
||||
};
|
||||
|
||||
state = {
|
||||
loading: false,
|
||||
errors: {},
|
||||
|
@ -78,7 +82,13 @@ class AddStaffModal extends React.Component {
|
|||
level: form.level + 1,
|
||||
departments: JSON.stringify(departments)
|
||||
}
|
||||
}).then(this.context.closeModal).catch((result) => {
|
||||
}).then(() => {
|
||||
this.context.closeModal();
|
||||
|
||||
if(this.props.onSuccess) {
|
||||
this.props.onSuccess();
|
||||
}
|
||||
}).catch((result) => {
|
||||
this.setState({
|
||||
loading: false,
|
||||
error: result.message
|
||||
|
|
|
@ -26,10 +26,7 @@ class AdminPanelStaffMembers extends React.Component {
|
|||
};
|
||||
|
||||
componentDidMount() {
|
||||
API.call({
|
||||
path: '/staff/get-all',
|
||||
data: {}
|
||||
}).then(this.onStaffRetrieved.bind(this));
|
||||
this.retrieveStaffMembers();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -48,7 +45,7 @@ class AdminPanelStaffMembers extends React.Component {
|
|||
}
|
||||
|
||||
onAddNewStaff() {
|
||||
ModalContainer.openModal(<AddStaffModal />);
|
||||
ModalContainer.openModal(<AddStaffModal onSuccess={this.retrieveStaffMembers.bind(this)} />);
|
||||
}
|
||||
|
||||
getDepartmentDropdownProps() {
|
||||
|
@ -78,6 +75,7 @@ class AdminPanelStaffMembers extends React.Component {
|
|||
|
||||
return staffList.map(staff => {
|
||||
return _.extend({}, staff, {
|
||||
profilePic: (staff.profilePic) ? API.getFileLink(staff.profilePic) : (API.getURL() + '/images/profile.png'),
|
||||
name: (
|
||||
<Link className="admin-panel-staff-members__link" to={'/admin/panel/staff/view-staff/' + staff.id}>
|
||||
{staff.name}
|
||||
|
@ -99,6 +97,13 @@ class AdminPanelStaffMembers extends React.Component {
|
|||
return departments;
|
||||
}
|
||||
|
||||
retrieveStaffMembers() {
|
||||
API.call({
|
||||
path: '/staff/get-all',
|
||||
data: {}
|
||||
}).then(this.onStaffRetrieved.bind(this));
|
||||
}
|
||||
|
||||
onStaffRetrieved(result) {
|
||||
if(result.status == 'success'){
|
||||
this.setState({
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import React from 'react';
|
||||
import {browserHistory} from 'react-router';
|
||||
import {connect} from 'react-redux';
|
||||
import _ from 'lodash';
|
||||
|
||||
import i18n from 'lib-app/i18n';
|
||||
import API from 'lib-app/api-call';
|
||||
import SessionActions from 'actions/session-actions';
|
||||
|
||||
import StaffEditor from 'app/admin/panel/staff/staff-editor';
|
||||
import Header from 'core-components/header';
|
||||
|
@ -17,12 +19,7 @@ class AdminPanelViewStaff extends React.Component {
|
|||
};
|
||||
|
||||
componentDidMount() {
|
||||
API.call({
|
||||
path: '/staff/get',
|
||||
data: {
|
||||
staffId: this.props.params.staffId
|
||||
}
|
||||
}).then(this.onStaffRetrieved.bind(this));
|
||||
this.retrieveStaff();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -37,15 +34,29 @@ class AdminPanelViewStaff extends React.Component {
|
|||
getProps() {
|
||||
return _.extend({}, this.state.userData, {
|
||||
staffId: this.props.params.staffId * 1,
|
||||
onDelete: this.onDelete.bind(this)
|
||||
onDelete: this.onDelete.bind(this),
|
||||
onChange: this.retrieveStaff.bind(this)
|
||||
});
|
||||
}
|
||||
|
||||
retrieveStaff() {
|
||||
API.call({
|
||||
path: '/staff/get',
|
||||
data: {
|
||||
staffId: this.props.params.staffId
|
||||
}
|
||||
}).then(this.onStaffRetrieved.bind(this));
|
||||
}
|
||||
|
||||
onStaffRetrieved(result) {
|
||||
this.setState({
|
||||
loading: false,
|
||||
userData: result.data
|
||||
});
|
||||
|
||||
if(this.props.userId == this.props.params.staffId) {
|
||||
this.props.dispatch(SessionActions.getUserData(null, null, true))
|
||||
}
|
||||
}
|
||||
|
||||
onDelete() {
|
||||
|
@ -53,4 +64,4 @@ class AdminPanelViewStaff extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default AdminPanelViewStaff;
|
||||
export default connect((store) => store.session)(AdminPanelViewStaff);
|
||||
|
|
|
@ -73,7 +73,7 @@ class StaffEditor extends React.Component {
|
|||
</div>
|
||||
<label className={this.getPictureWrapperClass()}>
|
||||
<div className="staff-editor__card-pic-background"></div>
|
||||
<img className="staff-editor__card-pic" src={(this.props.profilePic) ? API.getFileLink(this.props.profilePic) : (API.getURL() + '/images/logo.png')} />
|
||||
<img className="staff-editor__card-pic" src={(this.props.profilePic) ? API.getFileLink(this.props.profilePic) : (API.getURL() + '/images/profile.png')} />
|
||||
{(this.state.loadingPicture) ? <Loading className="staff-editor__card-pic-loading" size="large"/> : <Icon className="staff-editor__card-pic-icon" name="upload" size="4x"/>}
|
||||
<input className="staff-editor__image-uploader" type="file" multiple={false} accept="image/x-png,image/gif,image/jpeg" onChange={this.onProfilePicChange.bind(this)}/>
|
||||
</label>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
|
@ -27,8 +27,6 @@ let renderApplication = function () {
|
|||
render(<Provider store={store}>{routes}</Provider>, document.getElementById('app'));
|
||||
};
|
||||
window.store = store;
|
||||
store.dispatch(ConfigActions.init());
|
||||
store.dispatch(SessionActions.initSession());
|
||||
|
||||
let unsubscribe = store.subscribe(() => {
|
||||
console.log(store.getState());
|
||||
|
@ -38,3 +36,6 @@ let unsubscribe = store.subscribe(() => {
|
|||
renderApplication();
|
||||
}
|
||||
});
|
||||
|
||||
store.dispatch(ConfigActions.init());
|
||||
store.dispatch(SessionActions.initSession());
|
||||
|
|
|
@ -10,7 +10,7 @@ class GetStatsController extends Controller {
|
|||
'permission' => 'staff_1',
|
||||
'requestData' => [
|
||||
'period' => [
|
||||
'validation' => DataValidator::in(['week', 'month', 'quarter', 'year']),
|
||||
'validation' => DataValidator::in(['WEEK', 'MONTH', 'QUARTER', 'YEAR']),
|
||||
'error' => ERRORS::INVALID_PERIOD
|
||||
]
|
||||
]
|
||||
|
|
|
@ -74,7 +74,7 @@ describe'/system/get-stats' do
|
|||
@result = request('/system/get-stats', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
period: 'week'
|
||||
period: 'WEEK'
|
||||
})
|
||||
|
||||
def assertData(position, date, type, value)
|
||||
|
@ -126,7 +126,7 @@ describe'/system/get-stats' do
|
|||
@result = request('/system/get-stats', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token,
|
||||
period: 'week',
|
||||
period: 'WEEK',
|
||||
staffId: '1'
|
||||
})
|
||||
assertData(0, yesterday, 'CLOSE', '4')
|
||||
|
|
Loading…
Reference in New Issue