Browse Source

fix sprint_1

old_master
Listat.an 5 years ago
parent
commit
20ede23fe4
  1. 2
      src/containers/App/Router.jsx
  2. 1
      src/containers/App/actions.js
  3. 2
      src/containers/Layout/sidebar/SidebarContent.jsx
  4. 6
      src/containers/Profile/components/Actions/index.jsx
  5. 8
      src/containers/Profile/components/FormUser/index.jsx
  6. 44
      src/containers/Task/actions.js
  7. 2
      src/containers/Task/components/Contexmenu/index.jsx
  8. 126
      src/containers/Task/components/Data/index.jsx
  9. 50
      src/containers/Task/components/Form/index.jsx
  10. 2
      src/containers/Task/components/Menu/index.jsx
  11. 2
      src/containers/Task/index.js
  12. 2
      src/containers/Taxonomy/components/Data/index.jsx
  13. 4
      src/containers/User/actions.js
  14. 6
      src/containers/User/components/DataUser/index.jsx
  15. 13
      src/containers/User/components/FormUser/index.jsx
  16. 1
      src/lib/error.js
  17. 2
      src/redux/reducers/authReducer.js
  18. 4
      src/scss/main.scss

2
src/containers/App/Router.jsx

@ -37,7 +37,7 @@ const wrappedRoutes = () => ( @@ -37,7 +37,7 @@ const wrappedRoutes = () => (
<Route exact path="/profile/:id" component={Profile} />
<Route exact path="/group_permission" component={GroupPermission} />
<Route exact path="/group_permission/:id" component={GroupPermissionView} />
<Route exact path="/logs" component={Logs} />
<Route exact path="/logs_users" component={Logs} />
<Route exact path="/tasks" component={Task} />
<Route exact path="/taxonomy" component={Taxonomy} />
<Route exact path="/taxonomy/:type" component={Taxonomy} />

1
src/containers/App/actions.js

@ -12,6 +12,7 @@ export function me() { @@ -12,6 +12,7 @@ export function me() {
dispatch({type: 'AUTH_IS_LOAD'});
if(err.status == 402){
dispatch({type: 'LOGOUT'});
dispatch({type: 'AUTH_IS_BAN', status: true});
}
return null;

2
src/containers/Layout/sidebar/SidebarContent.jsx

@ -43,7 +43,7 @@ class SidebarContent extends Component { @@ -43,7 +43,7 @@ class SidebarContent extends Component {
<p className="sidebar__link-title">Dark Theme</p>
</button>
</SidebarCategory> */}
{profile.role == 'admin' && <SidebarLink title="Журнал подій" icon="layers" route="/logs" onClick={this.hideSidebar} />}
{profile.role == 'admin' && <SidebarLink title="Журнал подій" icon="layers" route="/logs_users" onClick={this.hideSidebar} />}
{getPermissionCheck('taxonomy', 'find', profile) ? <SidebarCategory title="Довідники" icon="book">
{getPermissionCheck('taxonomy', 'find', profile) ? <SidebarLink title="Групи задач" route="/taxonomy/task" onClick={this.hideSidebar} /> : null}
{getPermissionCheck('taxonomy', 'find', profile) ? <SidebarLink title="Підстави задач" route="/taxonomy/reasons_task" onClick={this.hideSidebar} /> : null}

6
src/containers/Profile/components/Actions/index.jsx

@ -8,9 +8,9 @@ import { updateUser, logoutUser } from '../../actions'; @@ -8,9 +8,9 @@ import { updateUser, logoutUser } from '../../actions';
class Actions extends Component {
render() {
const {profile, login_profile} = this.props;
if(!profile.id || profile.id == login_profile.id){
return null;
}
// if(!profile.id || profile.id == login_profile.id){
// return null;
// }
return (
<Col md={12} lg={12} xl={12}>
<Card>

8
src/containers/Profile/components/FormUser/index.jsx

@ -95,6 +95,14 @@ class FormUser extends Component { @@ -95,6 +95,14 @@ class FormUser extends Component {
placeholder="Новий пароль"
label="Новий пароль"
/>
<div style={{marginTop: -15, color: '#3498DB', cursor: 'pointer'}} onClick={() => {
var rnd = '';
while (rnd.length < 7)
rnd += Math.random().toString(36).substring(2);
rnd.substring(0, 7);
this.props.change('password', rnd);
this.props.change('password_confirm', rnd);
}}>Згенерувати пароль</div>
<Field
name='password_confirm'
component={InputField}

44
src/containers/Task/actions.js

@ -20,6 +20,30 @@ export function getTasks(filter, spiner=true) { @@ -20,6 +20,30 @@ export function getTasks(filter, spiner=true) {
};
}
export function taskClone(body) {
return async (dispatch) => {
try {
let result = await restClient.post('task', 'clone', body)
console.log("TCL: taskClone -> result", result)
return result;
} catch (error) {
return processError(error, dispatch);
}
// return Promise.all([
// restClient.find('task', filter),
// // restClient.get('task', 'count', filter),
// ]).then(([data, count, users]) => {
// dispatch({ type: 'GET_TASKS', data, filter, count: 0 });
// dispatch(getUsersNotification());
// return null;
// }).catch(err => {
// dispatch({type: 'GET_TASKS', data: [], filter, count: 0});
// return processError(err, dispatch);
// });
};
}
export function actionsComments(actions, task_id) {
let fetch = [];
if(actions.create_comments && actions.create_comments.length){
@ -166,15 +190,17 @@ export function deleteTask(ids) { @@ -166,15 +190,17 @@ export function deleteTask(ids) {
ids = [ids]
}
return (dispatch) => {
return Promise.all(ids.map(id => restClient.delete('task', id))) .then((result) => {
// ids.forEach(id => {
// dispatch({ type: 'DELETE_TASK', id });
// })
return null;
}).catch(err => {
return processError(err, dispatch);
});
return async (dispatch) => {
await restClient.post('task', 'bulk_delete', {ids});
return null;
// return Promise.all(ids.map(id => restClient.delete('task', id))) .then((result) => {
// // ids.forEach(id => {
// // dispatch({ type: 'DELETE_TASK', id });
// // })
// return null;
// }).catch(err => {
// return processError(err, dispatch);
// });
};
}

2
src/containers/Task/components/Contexmenu/index.jsx

@ -201,7 +201,7 @@ class Contexmenu extends Component { @@ -201,7 +201,7 @@ class Contexmenu extends Component {
case 'new':
this.props.setItemTask({
status: 'active',
name: 'Нова задача',
name: '',
create_date: moment(),
start_date: moment(),
end_date: moment().add(1, 'days'),

126
src/containers/Task/components/Data/index.jsx

@ -213,13 +213,6 @@ class Data extends Component { @@ -213,13 +213,6 @@ class Data extends Component {
</div>
),
},
// {
// title: 'Статус',
// dataIndex: 'status_title',
// key: 'status_title',
// sortOrder: sortedInfo.columnKey === 'status_title' && sortedInfo.order,
// sorter: (a, b) => this.sortString(a.status_title, b.status_title),
// },
{
title: 'Початок',
dataIndex: 'start_date',
@ -242,65 +235,11 @@ class Data extends Component { @@ -242,65 +235,11 @@ class Data extends Component {
sorter: (a, b) => this.sortDate(a.end_date, b.end_date),
sortOrder: sortedInfo.columnKey === 'end_date' && sortedInfo.order,
},
// {
// title: 'Котроль',
// dataIndex: 'controll_date',
// key: 'controll_date',
// render: (date) => {
// return date ? moment(date).format('DD-MM-YYYY') : '';
// },
// sorter: (a, b) => this.sortDate(a.controll_date, b.controll_date),
// sortOrder: sortedInfo.columnKey === 'controll_date' && sortedInfo.order,
// },
// {
// title: 'Виконано',
// dataIndex: 'done_date',
// key: 'done_date',
// render: (value, record) => {
// return value ? moment(value).format('DD-MM-YYYY') : ''
// },
// sorter: (a, b) => this.sortDate(a.done_date, b.done_date),
// sortOrder: sortedInfo.columnKey === 'done_date' && sortedInfo.order,
// },
// {
// title: 'Якість',
// dataIndex: 'quality',
// key: 'quality',
// sorter: (a, b) => {
// if (a.quality < b.quality)
// return -1;
// if (a.quality > b.quality)
// return 1;
// return 0;
// },
// sortOrder: sortedInfo.columnKey === 'quality' && sortedInfo.order,
// },
// {
// title: 'Хто створив',
// dataIndex: 'user_created',
// key: 'user_created',
// sorter: true,
// render: (user_id) => {
// let index = _.findIndex(users, ['id', user_id]);
// if(~index){
// return users[index].name
// }
// return user_id;
// },
// sortOrder: sortedInfo.columnKey === 'user_created' && sortedInfo.order,
// },
{
title: 'Хто створив',
dataIndex: 'user_created_title',
key: 'user_created_title',
sorter: (a, b) => this.sortString(a.user_created_title, b.user_created_title),
// render: (user_id) => {
// let index = _.findIndex(users, ['id', user_id]);
// if(~index){
// return users[index].name
// }
// return user_id;
// },
sortOrder: sortedInfo.columnKey === 'user_created_title' && sortedInfo.order,
render: (text, record) => (
<div style={{
@ -313,20 +252,6 @@ class Data extends Component { @@ -313,20 +252,6 @@ class Data extends Component {
</div>
),
},
// {
// title: 'Кому виконувати',
// dataIndex: 'user_done',
// key: 'user_done',
// sorter: true,
// render: (user_id) => {
// let index = _.findIndex(users, ['id', user_id]);
// if(~index){
// return users[index].name
// }
// return user_id;
// },
// sortOrder: sortedInfo.columnKey === 'user_done' && sortedInfo.order,
// },
{
title: 'Виконавець',
dataIndex: 'user_done_title',
@ -344,13 +269,6 @@ class Data extends Component { @@ -344,13 +269,6 @@ class Data extends Component {
</div>
),
},
// {
// title: 'Заявка',
// dataIndex: 'base',
// key: 'base',
// sorter: (a, b) => this.sortString(a.base, b.base),
// sortOrder: sortedInfo.columnKey === 'base' && sortedInfo.order,
// },
{
title: '',
key: 'action',
@ -361,25 +279,7 @@ class Data extends Component { @@ -361,25 +279,7 @@ class Data extends Component {
{record.documents && record.documents.length ? <i style={{color: 'rgba(162,162,162,.65)'}} className="fal fa-paperclip"></i> : null}
{record.documents && record.documents.length ? <span style={{padding: '2px'}}> </span> : null}
{record.comments && record.comments.length ? <i style={{color: 'rgba(162,162,162,.65)'}} className="fal fa-comment"></i> : null}
{/* {record.comments && record.comments.length ? <span style={{padding: '2px'}}> </span> : null} */}
{/* {profile && profile.favorites && profile.favorites.indexOf(record.id) > -1 ? <i className="fas fa-star"></i> : null} */}
</span>
// <span>
// {this.getCheckPermissionsTask('update', record) ? <a className="lnr lnr-pencil" href='javascript:;' onClick={() => {
// this.props.setItemTask(record);
// this.props.showModal(true);
// }}></a> : null}
// <span style={{padding: '10px'}}> </span>
// {this.getCheckPermissionsTask('destroy', record) ? <Popconfirm
// title="Ви справді хочете видалити цю задачу?"
// onConfirm={() => {
// this.props.deleteTask(record.id)
// }}
// >
// <a className="lnr lnr-trash" href="javascript:;"></a>
// </Popconfirm> : null}
// </span>
),
}
];
@ -400,31 +300,7 @@ class Data extends Component { @@ -400,31 +300,7 @@ class Data extends Component {
key: 'status_title',
sortOrder: sortedInfo.columnKey === 'status_title' && sortedInfo.order,
sorter: (a, b) => this.sortString(a.status_title, b.status_title),
},
// {
// title: 'Дії',
// key: 'action',
// width: 100,
// // fixed: 'right',
// render: (text, record) => (
// <span>
// {this.getCheckPermissionsTask('update', record) ? <a className="lnr lnr-pencil" href='javascript:;' onClick={() => {
// this.props.setItemTask(record);
// this.props.showModal(true);
// }}></a> : null}
// <span style={{padding: '10px'}}> </span>
// {this.getCheckPermissionsTask('destroy', record) ? <Popconfirm
// title="Ви справді хочете видалити цю задачу?"
// onConfirm={() => {
// this.props.deleteTask(record.id)
// }}
// >
// <a className="lnr lnr-trash" href="javascript:;"></a>
// </Popconfirm> : null}
// </span>
// ),
// }
}
]
}

50
src/containers/Task/components/Form/index.jsx

@ -8,7 +8,7 @@ import SelectField from '../../../../components/Fields/SelectField'; @@ -8,7 +8,7 @@ import SelectField from '../../../../components/Fields/SelectField';
import SelectMultyField from '../../../../components/Fields/SelectMultyField';
import DateField from '../../../../components/Fields/DateField';
import TextField from '../../../../components/Fields/TextField';
import { showModal, updateTask, createTask, getControllers, actionsComments, actionsDocuments, getTasks, createTaxonomy } from '../../actions';
import { showModal, updateTask, createTask, getControllers, actionsComments, actionsDocuments, getTasks, createTaxonomy, taskClone } from '../../actions';
import {ButtonToolbar, Button} from 'reactstrap'
import _ from 'lodash'
import './style.scss'
@ -90,7 +90,7 @@ class Form extends Component { @@ -90,7 +90,7 @@ class Form extends Component {
}
};
submit = (values) => {
submit = async (values) => {
let tmp_values = _.cloneDeep(values);
delete tmp_values.comments;
delete tmp_values.documents;
@ -111,33 +111,34 @@ class Form extends Component { @@ -111,33 +111,34 @@ class Form extends Component {
}
if(values.id){
this.props.updateTask(values.id, tmp_values).then(() => {
this.props.showModal(false);
this.props.getTasks(this.props.filter)
});
await this.props.updateTask(values.id, tmp_values);
} else {
if(tmp_values.user_done && Array.isArray(tmp_values.user_done)){
Promise.all(tmp_values.user_done.map(item => this.props.createTask({...tmp_values, user_done: item }).then((result) => {
this.props.actionsComments(this.state.action_comments, result.id);
this.props.actionsDocuments(this.state.action_documents, result.id);
// for(const user_done of tmp_values.user_done){
// }
let task = await this.props.createTask({...tmp_values, user_done: tmp_values.user_done[0] });
await this.props.actionsComments(this.state.action_comments, task.id);
await this.props.actionsDocuments(this.state.action_documents, task.id);
if(tmp_values.user_done.length > 1){
await this.props.taskClone({
user_ids: tmp_values.user_done.filter((id, index) => index > 0),
task_id: task.id
})
)).then(() => {
this.props.showModal(false);
this.props.getTasks(this.props.filter)
})
}
} else if(tmp_values.user_done) {
this.props.createTask(tmp_values).then((result) => {
this.props.actionsComments(this.state.action_comments, result.id);
this.props.actionsDocuments(this.state.action_documents, result.id);
return null;
}).then(() => {
this.props.showModal(false);
this.props.getTasks(this.props.filter)
});
let task = await this.props.createTask({...tmp_values});
await this.props.actionsComments(this.state.action_comments, task.id);
await this.props.actionsDocuments(this.state.action_documents, task.id);
}
}
this.props.showModal(false);
this.props.getTasks(this.props.filter)
}
createTaxonomy = (data) => {
@ -177,8 +178,6 @@ class Form extends Component { @@ -177,8 +178,6 @@ class Form extends Component {
let dateStart = returnFormValues.start_date;
let dateEnd = returnFormValues.end_date;
return (
<div className="tabs tabs--justify tabs--bordered-top">
<div className="tabs__wrap">
@ -621,6 +620,7 @@ const mapDispatchToProps = { @@ -621,6 +620,7 @@ const mapDispatchToProps = {
createTask,
actionsDocuments,
createTaxonomy,
taskClone,
}
export default connect(mapStateToProps, mapDispatchToProps)(Form)

2
src/containers/Task/components/Menu/index.jsx

@ -110,7 +110,7 @@ class MenuTask extends Component { @@ -110,7 +110,7 @@ class MenuTask extends Component {
case 'new':
this.props.setItemTask({
status: 'active',
name: 'Нова задача',
name: '',
create_date: moment(),
start_date: moment(),
end_date: moment().add(1, 'days'),

2
src/containers/Task/index.js

@ -129,7 +129,7 @@ class Task extends Component { @@ -129,7 +129,7 @@ class Task extends Component {
<Button color="primary" size='sm' onClick={() => {
this.props.setItemTask({
status: 'active',
name: 'Нова задача',
name: '',
create_date: moment(),
start_date: moment(),
end_date: moment().add(1, 'days'),

2
src/containers/Taxonomy/components/Data/index.jsx

@ -87,7 +87,7 @@ class Data extends Component { @@ -87,7 +87,7 @@ class Data extends Component {
}}></a> : null}
<span style={{padding: '10px'}}> </span>
{profile.id == record.id || !getPermissionCheck('taxonomy', 'destroy', profile) || (record.is_default && record.type == "task") ? null : <Popconfirm
{!getPermissionCheck('taxonomy', 'destroy', profile) || (record.is_default && record.type == "task") ? null : <Popconfirm
title="Ви справді хочете видалити цей елемент?"
onConfirm={() => {
this.props.deleteTaxonomy(record.id)

4
src/containers/User/actions.js

@ -128,7 +128,7 @@ export function createUser(data, image) { @@ -128,7 +128,7 @@ export function createUser(data, image) {
}
}).then(result => {
dispatch({ type: 'CREATE_USER', data: result });
return null;
return {status: true};
}).catch(err => {
return processError(err, dispatch);
});
@ -160,7 +160,7 @@ export function updateUser(id, data, image, login_id) { @@ -160,7 +160,7 @@ export function updateUser(id, data, image, login_id) {
if (id == login_id){
dispatch({ type: 'GET_PROFILE_UPDATE', data: result });
}
return null;
return {status: true};
}).catch(err => {
return processError(err, dispatch);
});

6
src/containers/User/components/DataUser/index.jsx

@ -102,8 +102,8 @@ class DataUser extends Component { @@ -102,8 +102,8 @@ class DataUser extends Component {
})
}
user.date_login_mobile_at_string = moment(user.date_login_mobile_at).format('DD-MM-YYYY HH:mm:ss');
user.date_login_desktop_at_string = moment(user.date_login_desktop_at).format('DD-MM-YYYY HH:mm:ss');
user.date_login_mobile_at_string = user.date_login_mobile_at_string ? moment(user.date_login_mobile_at).format('DD-MM-YYYY HH:mm:ss') : 'Ніколи';
user.date_login_desktop_at_string = user.date_login_desktop_at ? moment(user.date_login_desktop_at).format('DD-MM-YYYY HH:mm:ss') : 'Ніколи';
return user;
})
@ -121,7 +121,7 @@ class DataUser extends Component { @@ -121,7 +121,7 @@ class DataUser extends Component {
dataIndex: 'avatar',
key: 'avatar',
render: (text, record) => {
return record.icon ? <img style={{maxHeight: 30, maxWidth: 30}} src={config.apiUrl + record.avatar}/> : <img style={{maxHeight: 30, maxWidth: 30}} src={`${process.env.PUBLIC_URL}/img/default-avatar.jpg`}/>;
return record.avatar ? <img style={{maxHeight: 30, maxWidth: 30}} src={config.apiUrl + record.avatar}/> : <img style={{maxHeight: 30, maxWidth: 30}} src={`${process.env.PUBLIC_URL}/img/default-avatar.jpg`}/>;
}
},
{

13
src/containers/User/components/FormUser/index.jsx

@ -61,16 +61,20 @@ class FormUser extends Component { @@ -61,16 +61,20 @@ class FormUser extends Component {
}
if(values.id){
this.props.updateUser(values.id, _.cloneDeep(values), this.state.image, profile.id).then(() => {
this.props.updateUser(values.id, _.cloneDeep(values), this.state.image, profile.id).then((result) => {
this.props.getUsers(this.props.filter);
if((profile.id != values.id) && (values.password || initialValues.phone != values.phone)){
this.props.logoutUser(values.id);
}
this.props.showModal(false);
if(result.status){
this.props.showModal(false);
}
});
} else {
this.props.createUser(values, this.state.image).then(() => {
this.props.showModal(false);
this.props.createUser(values, this.state.image).then((result) => {
if(result.status){
this.props.showModal(false);
}
});
}
@ -201,6 +205,7 @@ class FormUser extends Component { @@ -201,6 +205,7 @@ class FormUser extends Component {
rnd += Math.random().toString(36).substring(2);
rnd.substring(0, 7);
this.props.change('password', rnd);
this.props.change('password_confirm', rnd);
}}>Згенерувати пароль</div>
</div>
<div className="col-12 col-md-6" style={{padding: 0, paddingLeft: '7px'}}>

1
src/lib/error.js

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
export default function processError(error, dispatch) {
if(error.status == 402){
dispatch({type: 'LOGOUT'});
dispatch({type: 'AUTH_IS_BAN', status: true});
return;
}

2
src/redux/reducers/authReducer.js

@ -15,7 +15,7 @@ export default function (state = initialState, action) { @@ -15,7 +15,7 @@ export default function (state = initialState, action) {
case 'AUTH_IS_LOAD':
return Object.assign({}, state, { is_load: true });
case 'AUTH_IS_BAN':
return Object.assign({}, state, { is_ban: action.status });
return Object.assign({}, state, { is_ban: action.status, token: '' });
case 'SET_TOKEN':
return Object.assign({}, state, { token: action.token });
case 'GET_PROFILE':

4
src/scss/main.scss

@ -96,6 +96,10 @@ span{ @@ -96,6 +96,10 @@ span{
opacity: 1;
}
.rc-notification{
z-index: 1051;
}
.ant-checkbox-inner{
width: 18px;
height: 18px;

Loading…
Cancel
Save