Ivan - Updates needed for dev3 deploy [skip ci]

This commit is contained in:
ivan 2016-12-13 21:10:49 -03:00
parent 959c9525ed
commit 8d2033ec31
9 changed files with 81 additions and 45 deletions

View File

@ -30,7 +30,7 @@ export default {
updateData() { updateData() {
return { return {
type: 'UPDATE_DEPARTMENTS', type: 'UPDATE_DATA',
payload: API.call({ payload: API.call({
path: '/system/get-settings', path: '/system/get-settings',
data: {} data: {}

View File

@ -76,7 +76,7 @@ class AddStaffModal extends React.Component {
email: form.email, email: form.email,
password: form.password, password: form.password,
level: form.level + 1, level: form.level + 1,
department: JSON.stringify(departments) departments: JSON.stringify(departments)
} }
}).then(this.context.closeModal).catch((result) => { }).then(this.context.closeModal).catch((result) => {
this.setState({ this.setState({

View File

@ -136,7 +136,7 @@ class AdminPanelDepartments extends React.Component {
if(this.state.selectedIndex !== -1) { if(this.state.selectedIndex !== -1) {
API.call({ API.call({
path: '/staff/edit-department', path: '/system/edit-department',
data: { data: {
departmentId: this.getCurrentDepartment().id, departmentId: this.getCurrentDepartment().id,
name: form.name name: form.name
@ -147,9 +147,9 @@ class AdminPanelDepartments extends React.Component {
}).catch(this.onItemChange.bind(this, -1)); }).catch(this.onItemChange.bind(this, -1));
} else { } else {
API.call({ API.call({
path: '/staff/add-department', path: '/system/add-department',
data: { data: {
name: form.title name: form.name
} }
}).then(() => { }).then(() => {
this.retrieveDepartments(); this.retrieveDepartments();
@ -172,7 +172,7 @@ class AdminPanelDepartments extends React.Component {
deleteDepartment() { deleteDepartment() {
API.call({ API.call({
path: '/staff/delete-department', path: '/system/delete-department',
data: { data: {
departmentId: this.getCurrentDepartment().id, departmentId: this.getCurrentDepartment().id,
transferDepartmentId: this.getDropDownItemId() transferDepartmentId: this.getDropDownItemId()

View File

@ -73,8 +73,8 @@ class StaffEditor extends React.Component {
</Form> </Form>
<span className="separator staff-editor__separator" /> <span className="separator staff-editor__separator" />
<Form className="staff-editor__update-password" onSubmit={this.onSubmit.bind(this)}> <Form className="staff-editor__update-password" onSubmit={this.onSubmit.bind(this)}>
<FormField name="password" validation="PASSWORD" required label={i18n('PASSWORD')} fieldProps={{size: 'large'}}/> <FormField name="password" validation="PASSWORD" required label={i18n('PASSWORD')} fieldProps={{size: 'large', password: true}}/>
<FormField name="rpassword" validation="REPEAT_PASSWORD" required label={i18n('REPEAT_PASSWORD')} fieldProps={{size: 'large'}}/> <FormField name="rpassword" validation="REPEAT_PASSWORD" required label={i18n('REPEAT_PASSWORD')} fieldProps={{size: 'large', password: true}}/>
<SubmitButton size="medium" className="staff-editor__submit-button">{i18n('UPDATE_PASSWORD')}</SubmitButton> <SubmitButton size="medium" className="staff-editor__submit-button">{i18n('UPDATE_PASSWORD')}</SubmitButton>
</Form> </Form>
{(!this.props.myAccount) ? this.renderLevelForm() : null} {(!this.props.myAccount) ? this.renderLevelForm() : null}
@ -86,10 +86,7 @@ class StaffEditor extends React.Component {
<div className="col-md-4"> <div className="col-md-4">
<div className="staff-editor__departments"> <div className="staff-editor__departments">
<div className="staff-editor__departments-title">{i18n('Departments')}</div> <div className="staff-editor__departments-title">{i18n('Departments')}</div>
<Form values={{departments: this.state.departments}} onChange={form => this.setState({departments: form.departments})} onSubmit={this.onSubmit.bind(this)}> {(!this.props.myAccount) ? this.renderDepartmentsForm() : this.renderDepartmentsInfo()}
<FormField name="departments" field="checkbox-group" fieldProps={{items: this.getDepartments()}} />
<SubmitButton size="medium">{i18n('UPDATE_DEPARTMENTS')}</SubmitButton>
</Form>
</div> </div>
</div> </div>
<div className="col-md-8"> <div className="col-md-8">
@ -118,6 +115,24 @@ class StaffEditor extends React.Component {
); );
} }
renderDepartmentsForm() {
return (
<Form values={{departments: this.state.departments}} onChange={form => this.setState({departments: form.departments})} onSubmit={this.onSubmit.bind(this)}>
<FormField name="departments" field="checkbox-group" fieldProps={{items: this.getDepartments()}} />
<SubmitButton size="medium">{i18n('UPDATE_DEPARTMENTS')}</SubmitButton>
</Form>
);
}
renderDepartmentsInfo() {
return (
<Form values={{departments: this.state.departments}}>
<FormField name="departments" field="checkbox-group" fieldProps={{items: this.getDepartments()}} />
</Form>
);
}
renderTickets() { renderTickets() {
return ( return (
<div> <div>

View File

@ -1047,35 +1047,5 @@ module.exports = [
data: {} data: {}
}; };
} }
},
{
path: '/staff/add-department',
time: 100,
response: function () {
return {
status: 'success',
data: {}
};
}
},
{
path: '/staff/edit-department',
time: 100,
response: function () {
return {
status: 'success',
data: {}
};
}
},
{
path: '/staff/delete-department',
time: 100,
response: function () {
return {
status: 'success',
data: {}
};
}
} }
]; ];

View File

@ -16,5 +16,35 @@ module.exports = [
} }
}; };
} }
},
{
path: '/staff/add-department',
time: 100,
response: function () {
return {
status: 'success',
data: {}
};
}
},
{
path: '/staff/edit-department',
time: 100,
response: function () {
return {
status: 'success',
data: {}
};
}
},
{
path: '/staff/delete-department',
time: 100,
response: function () {
return {
status: 'success',
data: {}
};
}
} }
]; ];

View File

@ -7,7 +7,7 @@ class GetUserByIdController extends Controller {
public function validations() { public function validations() {
return [ return [
'permission' => 'staff_2', 'permission' => 'staff_1',
'requestData' => [ 'requestData' => [
'userId' => [ 'userId' => [
'validation' => DataValidator::dataStoreId('user'), 'validation' => DataValidator::dataStoreId('user'),
@ -20,12 +20,21 @@ class GetUserByIdController extends Controller {
public function handler() { public function handler() {
$userId = Controller::request('userId'); $userId = Controller::request('userId');
$user = User::getDataStore($userId); $user = User::getDataStore($userId);
$staff = Controller::getLoggedUser();
$tickets = new DataStoreList();
foreach($user->sharedTicketList as $ticket) {
if($staff->sharedDepartmentList->includesId($ticket->department->id)) {
$tickets->add($ticket);
}
}
Response::respondSuccess([ Response::respondSuccess([
'name' => $user->name, 'name' => $user->name,
'email' => $user->email, 'email' => $user->email,
'signupDate' => $user->signupDate, 'signupDate' => $user->signupDate,
'tickets' => $user->sharedTicketList->toArray() 'tickets' => $tickets->toArray()
]); ]);
} }
} }

View File

@ -6,7 +6,7 @@ class GetUsersController extends Controller {
public function validations() { public function validations() {
return[ return[
'permission' => 'staff_2', 'permission' => 'staff_1',
'requestData' => [ 'requestData' => [
'page' => [ 'page' => [
'validation' => DataValidator::numeric(), 'validation' => DataValidator::numeric(),

View File

@ -33,6 +33,18 @@ class DataStoreList implements IteratorAggregate {
} }
} }
public function includesId($id) {
$includes = false;
foreach($this->list as $item) {
if($item->id == $id) {
$includes = true;
}
}
return $includes;
}
public function toBeanList() { public function toBeanList() {
$beanList = []; $beanList = [];