Browse Source

fixes sprint2

old_master
Listat.an 4 years ago
parent
commit
bd9929ded0
  1. 4
      __run.bat
  2. 20
      src/components/PermissionsField/components/Item/components/SubType/index.jsx
  3. 1
      src/components/PermissionsField/components/Item/index.jsx
  4. 23
      src/containers/App/NotificationIsPrivateTab.jsx
  5. 10
      src/containers/App/NotificationIsPrivateTab.scss
  6. 19
      src/containers/App/Router.jsx
  7. 95
      src/containers/App/detectPrivateMode.js
  8. 13
      src/containers/Factory/components/FormFactory/index.jsx
  9. 13
      src/containers/Task/components/Data/index.jsx

4
__run.bat

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
REM SET REACT_APP_API_URL=http://localhost:1337
SET REACT_APP_API_URL=http://8c9e8772f1e1.ngrok.io
SET REACT_APP_API_URL=http://localhost:1337
REM SET REACT_APP_API_URL=http://8c9e8772f1e1.ngrok.io
yarn start

20
src/components/PermissionsField/components/Item/components/SubType/index.jsx

@ -11,22 +11,6 @@ class SubType extends Component { @@ -11,22 +11,6 @@ class SubType extends Component {
}
componentWillMount() {
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
}
componentWillUnmount() {
}
render() {
let {value, factories, users} = this.props;
@ -36,6 +20,10 @@ class SubType extends Component { @@ -36,6 +20,10 @@ class SubType extends Component {
let name = value['type'];
if(name == 'filter_factory'){
return <div />
}
let lable = '';
switch (name) {

1
src/components/PermissionsField/components/Item/index.jsx

@ -50,6 +50,7 @@ class Item extends Component { @@ -50,6 +50,7 @@ class Item extends Component {
<Select.Option value={'factory'}>Підприємство</Select.Option>
<Select.Option value={'user'}>Користувачі</Select.Option>
{profile.role == 'admin' && <Select.Option value={'tabs'}>Сторінки</Select.Option>}
<Select.Option value={'filter_factory'}>Показувати фільтер "Підприємств"</Select.Option>
</Select>
</div>
<SubType {...this.props} onChange={this.onChange}/>

23
src/containers/App/NotificationIsPrivateTab.jsx

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
import React, { Component } from 'react';
import detectPrivateMode from './detectPrivateMode';
import './NotificationIsPrivateTab.scss';
class NotificationIsPrivateTab extends Component {
state = {is_private: false}
componentDidMount(){
detectPrivateMode((is_private) => {
this.setState({is_private})
})
}
render() {
const {is_private} = this.state;
if(!is_private){
return null;
}
return (
<div className="NotificationIsPrivateTab"><i className="fal fa-exclamation-triangle"></i> В приватній вкладці програма буде працювати не коректно</div>
);
}
}
export default NotificationIsPrivateTab;

10
src/containers/App/NotificationIsPrivateTab.scss

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
.NotificationIsPrivateTab{
position: absolute;
z-index: 99999999;
padding: 10px;
background: #FFB818;
border: 5px;
left: 240px;
top: 10px;
color: white;
}

19
src/containers/App/Router.jsx

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
import React from 'react';
import React, {useEffect, useState} from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';
import Layout from '../Layout/index';
import MainWrapper from './MainWrapper';
@ -18,21 +18,14 @@ import Taxonomy from '../Taxonomy'; @@ -18,21 +18,14 @@ import Taxonomy from '../Taxonomy';
import Ban from '../Ban';
import Logs from '../Logs';
import Ips from '../Ips';
import NotificationIsPrivateTab from './NotificationIsPrivateTab';
const Pages = () => (
<Switch>
<Route path="/pages/one" component={ExamplePageOne} />
<Route path="/pages/two" component={ExamplePageTwo} />
</Switch>
);
const wrappedRoutes = () => (
<div>
const wrappedRoutes = () => {
return <div>
<NotificationIsPrivateTab />
<Layout />
<div className="container__wrap" style={{position: 'relative'}}>
<Route exact path="/" component={()=><Redirect to="/tasks"/>}/>
<Route path="/pages" component={Pages} />
<Route exact path="/factory" component={Factory} />
<Route exact path="/user" component={User} />
<Route exact path="/profile/:id" component={Profile} />
@ -48,7 +41,7 @@ const wrappedRoutes = () => ( @@ -48,7 +41,7 @@ const wrappedRoutes = () => (
</div>
</div>
</div>
);
};
const Router = () => (
<MainWrapper>

95
src/containers/App/detectPrivateMode.js

@ -0,0 +1,95 @@ @@ -0,0 +1,95 @@
function retry(isDone, next) {
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false;
var id = window.setInterval(
function() {
if (isDone()) {
window.clearInterval(id);
next(is_timeout);
}
if (current_trial++ > max_retry) {
window.clearInterval(id);
is_timeout = true;
next(is_timeout);
}
},
10
);
}
function isIE10OrLater(user_agent) {
var ua = user_agent.toLowerCase();
if (ua.indexOf('msie') === 0 && ua.indexOf('trident') === 0) {
return false;
}
var match = /(?:msie|rv:)\s?([\d\.]+)/.exec(ua);
if (match && parseInt(match[1], 10) >= 10) {
return true;
}
return false;
}
export default function detectPrivateMode(callback) {
var is_private;
if (window.webkitRequestFileSystem) {
window.webkitRequestFileSystem(
window.TEMPORARY, 1,
function() {
is_private = false;
},
function(e) {
console.log(e);
is_private = true;
}
);
} else if (window.indexedDB && /Firefox/.test(window.navigator.userAgent)) {
var db;
try {
db = window.indexedDB.open('test');
} catch(e) {
is_private = true;
}
if (typeof is_private === 'undefined') {
retry(
function isDone() {
return db.readyState === 'done' ? true : false;
},
function next(is_timeout) {
if (!is_timeout) {
is_private = db.result ? false : true;
}
}
);
}
} else if (isIE10OrLater(window.navigator.userAgent)) {
is_private = false;
try {
if (!window.indexedDB) {
is_private = true;
}
} catch (e) {
is_private = true;
}
} else if (window.localStorage && /Safari/.test(window.navigator.userAgent)) {
try {
window.localStorage.setItem('test', 1);
} catch(e) {
is_private = true;
}
if (typeof is_private === 'undefined') {
is_private = false;
window.localStorage.removeItem('test');
}
}
retry(
function isDone() {
return typeof is_private !== 'undefined' ? true : false;
},
function next(is_timeout) {
callback(is_private);
}
);
}

13
src/containers/Factory/components/FormFactory/index.jsx

@ -10,6 +10,7 @@ import { genTree } from '../../../../lib/helper'; @@ -10,6 +10,7 @@ import { genTree } from '../../../../lib/helper';
import _ from 'lodash'
import SelectField from '../../../../components/Fields/SelectField';
import { createFactory, updateFactory, showModal } from '../../actions';
import SelectMultyField from '../../../../components/Fields/SelectMultyField';
@ -60,6 +61,18 @@ class FormFactory extends Component { @@ -60,6 +61,18 @@ class FormFactory extends Component {
label="Директор"
options={users.map(item => ({title: item.name, value: item.id}))}
/>
<Field
name='director_permissions'
component={SelectMultyField}
placeholder="Права доступу на підприємство"
label="Права доступу на підприємство"
options={[
{title: 'Перегляд задач', value: 'find'},
{title: 'Створення задач', value: 'create'},
{title: 'Редагування задач', value: 'update'},
{title: 'Видалення задач', value: 'destroy'},
]}
/>
<ButtonToolbar className="form__button-toolbar">
<Button color="primary" type="submit">Зберегти</Button>
</ButtonToolbar>

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

@ -174,9 +174,11 @@ class Data extends Component { @@ -174,9 +174,11 @@ class Data extends Component {
}
item.start_date_sort = item.start_date ? moment(item.start_date ).toDate().getTime() : 0;
item.end_date_sort = item.end_date ? moment(item.end_date).toDate().getTime() : 0;
item.start_date = item.start_date ? moment(item.start_date ).format('DD-MM-YYYY') : '';
item.done_date_sort = item.done_date ? moment(item.done_date).toDate().getTime() : 0;
item.start_date = item.start_date ? moment(item.start_date ).format('DD-MM-YYYY') : '';
item.end_date = item.end_date ? moment(item.end_date).format('DD-MM-YYYY') : '';
item.done_date = item.done_date ? moment(item.done_date).format('DD-MM-YYYY') : '';
item.favorite = profile && profile.favorites && profile.favorites.indexOf(item.id) > -1 ? 'так' : 'ні';
@ -246,6 +248,15 @@ class Data extends Component { @@ -246,6 +248,15 @@ class Data extends Component {
resizable: true,
filter: true,
},
{
name: 'Дата виконання',
key: 'done_date',
sort_field: 'done_date_sort',
width: 112,
sortable: true,
resizable: true,
filter: true,
},
{
name: 'Хто створив',
key: 'user_created_title',

Loading…
Cancel
Save