...
 
Commits (3)
......@@ -4097,7 +4097,8 @@
},
"ansi-regex": {
"version": "2.1.1",
"bundled": true
"bundled": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
......@@ -4115,11 +4116,13 @@
},
"balanced-match": {
"version": "1.0.0",
"bundled": true
"bundled": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
......@@ -4132,15 +4135,18 @@
},
"code-point-at": {
"version": "1.1.0",
"bundled": true
"bundled": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true
"bundled": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true
"bundled": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
......@@ -4243,7 +4249,8 @@
},
"inherits": {
"version": "2.0.3",
"bundled": true
"bundled": true,
"optional": true
},
"ini": {
"version": "1.3.5",
......@@ -4253,6 +4260,7 @@
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
......@@ -4265,17 +4273,20 @@
"minimatch": {
"version": "3.0.4",
"bundled": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"bundled": true
"bundled": true,
"optional": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
......@@ -4292,6 +4303,7 @@
"mkdirp": {
"version": "0.5.1",
"bundled": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
......@@ -4364,7 +4376,8 @@
},
"number-is-nan": {
"version": "1.0.1",
"bundled": true
"bundled": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
......@@ -4374,6 +4387,7 @@
"once": {
"version": "1.4.0",
"bundled": true,
"optional": true,
"requires": {
"wrappy": "1"
}
......@@ -4449,7 +4463,8 @@
},
"safe-buffer": {
"version": "5.1.1",
"bundled": true
"bundled": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
......@@ -4479,6 +4494,7 @@
"string-width": {
"version": "1.0.2",
"bundled": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
......@@ -4496,6 +4512,7 @@
"strip-ansi": {
"version": "3.0.1",
"bundled": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
......@@ -4534,11 +4551,13 @@
},
"wrappy": {
"version": "1.0.2",
"bundled": true
"bundled": true,
"optional": true
},
"yallist": {
"version": "3.0.2",
"bundled": true
"bundled": true,
"optional": true
}
}
},
......
window.env = {
// MEDIA
// Online Simcaa.it
// "PathImages": "http://www.simcaa.it/media/symbols/",
// "WaterImages": "http://www.simcaa.it/media/specialchar/",
// "CustomImage": "http://www.simcaa.it/scuole/media/custom/",
// "ApiImageUpload": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/imageupload",
// "ApiSymbolUpload": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/imageuploadtmp",
// "MediaImage": "http://www.simcaa.it/scuole/media/images/",
// "TmpImage": "http://www.simcaa.it/scuole/media/tmp/",
"PathImages": "http://www.simcaa.it/media/symbols/",
"WaterImages": "http://www.simcaa.it/media/specialchar/",
"CustomImage": "http://www.simcaa.it/scuole/media/custom/",
"ApiImageUpload": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/imageupload",
"ApiSymbolUpload": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/imageuploadtmp",
"MediaImage": "http://www.simcaa.it/scuole/media/images/",
"TmpImage": "http://www.simcaa.it/scuole/media/tmp/",
// Local
"PathImages": "http://10.0.0.132/media/symbols/",
"WaterImages": "http://10.0.0.132/media/watermark/",
"CustomImage": "http://10.0.0.132/media/custom/",
"ApiImageUpload": "http://10.0.0.132:8085/graphql/imageupload",
"ApiSymbolUpload": "http://10.0.0.132:8085/graphql/imageuploadtmp",
"MediaImage": "http://10.0.0.132/media/images/",
"TmpImage": "http://10.0.0.132/media/tmp/",
// "PathImages": "http://10.0.0.132/media/symbols/",
// "WaterImages": "http://10.0.0.132/media/watermark/",
// "CustomImage": "http://10.0.0.132/media/custom/",
// "ApiImageUpload": "http://10.0.0.132:8085/graphql/imageupload",
// "ApiSymbolUpload": "http://10.0.0.132:8085/graphql/imageuploadtmp",
// "MediaImage": "http://10.0.0.132/media/images/",
// "TmpImage": "http://10.0.0.132/media/tmp/",
// API SERVER
// Online Simcaa.it
// "GraphQLServer": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/query",
// "GraphQLServerNoAuth": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/query/noauth",
// "GraphQLLogin": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/login",
// "GraphQLCurrentUser": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/me",
// "GraphQLRefreshToken": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/jwtrefresh",
// "RestApiCard": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/card",
// "RestApiDuplicateProject": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/duplicateproject",
// "RestApiDuplicateChapter": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/duplicatechapter",
"GraphQLServer": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/query",
"GraphQLServerNoAuth": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/query/noauth",
"GraphQLLogin": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/login",
"GraphQLCurrentUser": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/me",
"GraphQLRefreshToken": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/jwtrefresh",
"RestApiCard": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/card",
"RestApiDuplicateProject": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/duplicateproject",
"RestApiDuplicateChapter": "http://www.simcaa.it/scuole/apisimcaa-graphql/public/graphql/duplicatechapter",
// Local
"GraphQLServer": "http://10.0.0.132:8085/graphql/query",
"GraphQLServerNoAuth": "http://10.0.0.132:8085/graphql/query/noauth",
"GraphQLLogin": "http://10.0.0.132:8085/graphql/login",
"GraphQLCurrentUser": "http://10.0.0.132:8085/graphql/me",
"GraphQLRefreshToken": "http://10.0.0.132:8085/graphql/jwtrefresh",
"RestApiCard": "http://10.0.0.132:8085/graphql/card",
"RestApiDuplicateProject": "http://10.0.0.132:8085/graphql/duplicateproject",
"RestApiDuplicateChapter": "http://10.0.0.132:8085/graphql/duplicatechapter",
// "GraphQLServer": "http://10.0.0.132:8085/graphql/query",
// "GraphQLServerNoAuth": "http://10.0.0.132:8085/graphql/query/noauth",
// "GraphQLLogin": "http://10.0.0.132:8085/graphql/login",
// "GraphQLCurrentUser": "http://10.0.0.132:8085/graphql/me",
// "GraphQLRefreshToken": "http://10.0.0.132:8085/graphql/jwtrefresh",
// "RestApiCard": "http://10.0.0.132:8085/graphql/card",
// "RestApiDuplicateProject": "http://10.0.0.132:8085/graphql/duplicateproject",
// "RestApiDuplicateChapter": "http://10.0.0.132:8085/graphql/duplicatechapter",
// CSS - remote
// "SemanticCSS": "http://10.0.0.132/includes/css/semantic.min.css",
......
......@@ -354,6 +354,27 @@ window.language = {
corretto: carta di credito
errato: il gatto con gli stivali
corretto: gatto con gli stivali`,
//PERMESSI
"can_manage_user": "Amministrazione utenti",
"can_manage_team": "Amministrazione dei team",
"can_manage_staff": "Amministrazione staff",
"can_manage_profile": "Amministrazione profili",
"can_manage_project": "Amministrazione progetti",
"can_manage_preload": "Amministrazione preload",
"can_upload_symbol": "Caricamento simboli",
"can_upload_media": "Caricamento materiale multimediale",
"can_access_admin": "Accesso ad area amministrazione",
"can_approve_symbol": "Approvazione simboli",
"can_create_project": "Creazione nuovi progetti",
"can_read_project": "Lettura progetti",
"can_update_project": "Modifica progetti",
"can_delete_project": "Eliminazione progetti",
"can_create_profile": "Creazione nuovi profili",
"can_read_profile": "Accesso ai profili",
"can_update_profile": "Modifica profili",
"can_delete_profile": "Eliminazione profili",
"can_show_filter": "Visualizza filtro dei progetti",
}
},
en: {
......@@ -710,6 +731,28 @@ window.language = {
corretto: carta di credito
errato: il gatto con gli stivali
corretto: gatto con gli stivali`,
// PERMISSIONS
"can_manage_user": "Users Management",
"can_manage_team": "Teams Management",
"can_manage_staff": "Staff Management" ,
"can_manage_profile": "Profiles Management",
"can_manage_project": "Projects Management",
"can_manage_preload": "Preload Management",
"can_upload_symbol": "Custom symbol upload",
"can_upload_media": "Custom media upload",
"can_access_admin": "Access to administration page",
"can_approve_symbol": "Symbol approval",
"can_create_project": "New projects creation",
"can_read_project": "See all projects",
"can_update_project": "Modify projects",
"can_delete_project": "Delete projects",
"can_create_profile": "Create new profiles",
"can_read_profile": "See all profiles",
"can_update_profile": "Modify profiles",
"can_delete_profile": "Delete profiles",
"can_show_filter": "See projects filter",
}
}
}
import React, { Component, Fragment } from 'react'
import React, { Component } from 'react'
import { translate } from 'react-i18next'
import {Button, Form, Checkbox} from 'semantic-ui-react'
import {Form, Checkbox} from 'semantic-ui-react'
import { isValidObject } from '../../store/functionUtils'
class EditUserForm extends Component{
constructor(props){
super(props)
}
handleChange(e,data){
}
class EditPermissionsForm extends Component{
render(){
console.log(this.props.permissions);
let fieldsLayout = this.props.permissions.map((perm,idx)=>{
return(
<Form.Field>
<label>Object.keys(perm)[0]</label>
<Checkbox toggle
key={idx}
checked={Object.values(perm)[0]}
onChange={this.handleChange}
/>
</Form.Field>
)
const { t } = this.props
let permissions = []
if(isValidObject(this.props.permissions)){
permissions = this.props.permissions
}else{
permissions = JSON.parse(this.props.permissions)
}
let permLayout = Object.keys(permissions).map((key,index)=>{
if(index%4 === 0){
let gLayout = []
Object.keys(permissions).map((k,i)=>{
if(i >= index && i < index+4){
gLayout.push(
<Form.Field key={i}>
<label>{t(k)}</label>
<Checkbox toggle
checked={permissions[k]}
onChange={()=>this.props.handlePermissionChange(k)}
/>
</Form.Field>
)
}
})
return(
<Form.Group widths='equal' style={{marginTop: '15px'}} key={index}>
{gLayout}
</Form.Group>
)
}
})
return(
<Form>
{fieldsLayout}
{permLayout}
</Form>
)
}
}
export default EditUserForm
export default translate('translations')(EditPermissionsForm)
import React, { Component, Fragment } from 'react'
import React, { Component } from 'react'
import {Button, Form, Message, Accordion, Input, Select, Icon} from 'semantic-ui-react'
import {Form, Accordion, Input, Select, Icon} from 'semantic-ui-react'
class EditUserForm extends Component{
constructor(props){
......@@ -44,14 +44,14 @@ class EditUserForm extends Component{
return(
<Form>
<Form.Group widths='equal'>
<Form.Field control={Input} label='Nome' value={this.props.name} onChange={this.props.nameChange()}/>
<Form.Field control={Input} label='Email' value={this.props.email} onChange={this.props.emailChange()}/>
<Form.Field control={Input} label='Username' value={this.props.username} onChange={this.props.usernameChange()}/>
<Form.Field control={Input} key={0} label='Nome' value={this.props.name} onChange={this.props.nameChange()}/>
<Form.Field control={Input} key={2} label='Email' value={this.props.email} onChange={this.props.emailChange()}/>
<Form.Field control={Input} key={3} label='Username' value={this.props.username} onChange={this.props.usernameChange()}/>
</Form.Group>
<Form.Group widths='equal'>
<Form.Field control={Input} label='Organizzazione' value={this.props.organization} onChange={this.props.orgChange()}/>
<Form.Field control={Input} label='Sito Web' value={this.props.link_web} onChange={this.props.linkWebChange()}/>
<Form.Field control={Select} label='Ruolo' options={this.state.roles} onChange={this.props.roleChange()} defaultValue={this.props.toUser.role_id}/>
<Form.Field control={Input} key={4} label='Organizzazione' value={this.props.organization} onChange={this.props.orgChange()}/>
<Form.Field control={Input} key={5} label='Sito Web' value={this.props.link_web} onChange={this.props.linkWebChange()}/>
<Form.Field control={Select} key={6} label='Ruolo' options={this.state.roles} onChange={this.props.roleChange()} defaultValue={this.props.toUser.role_id}/>
</Form.Group>
<Accordion as={Form.Field} >
<Accordion.Title active={this.state.modPass === 0} index={0} onClick={(e, titleProps)=>{titleProps.index === this.state.modPass ? this.setState({modPass: -1}) : this.setState({modPass: 0})}}>
......@@ -59,8 +59,8 @@ class EditUserForm extends Component{
Modifica password
</Accordion.Title>
<Accordion.Content active={this.state.modPass === 0}>
<Form.Field control={Input} label='Password attuale' onChange={this.props.oldPassChange()} type='password'/>
<Form.Field control={Input} label='Nuova password' onChange={this.props.newPassChange()} type='password'/>
<Form.Field control={Input} key={7} label='Password attuale' onChange={this.props.oldPassChange()} type='password'/>
<Form.Field control={Input} key={8} label='Nuova password' onChange={this.props.newPassChange()} type='password'/>
</Accordion.Content>
</Accordion>
</Form>
......
......@@ -4,7 +4,7 @@ import { Message } from 'semantic-ui-react'
class ErrorMessage extends Component{
render(){
return(
<Message negative hidden={this.props.hidden}>
<Message negative hidden={this.props.hidden} onDismiss={this.props.onDismiss}>
<Message.Header>{this.props.header}</Message.Header>
<p>{this.props.message}</p>
</Message>
......
......@@ -4,7 +4,7 @@ import { Message } from 'semantic-ui-react'
class PositiveMessage extends Component{
render(){
return(
<Message positive hidden={this.props.hidden}>
<Message positive hidden={this.props.hidden} onDismiss={this.props.onDismiss}>
<Message.Header>{this.props.header}</Message.Header>
<p>{this.props.message}</p>
</Message>
......
import React from 'react'
import { Table, Popup, Button, Icon } from 'semantic-ui-react'
import { Table, Popup, Button, Icon, Confirm } from 'semantic-ui-react'
import { translate } from 'react-i18next'
......@@ -7,7 +7,9 @@ class UsersTable extends React.Component {
constructor(props) {
super(props)
this.state = {
selected: -1
selected: -1,
openConfirm: false,
userToRemove: -1
}
}
clicked(id){
......@@ -17,15 +19,28 @@ class UsersTable extends React.Component {
if(this.state.selected === rowId) return true
else return false
}
remove(id){
this.props.removeUser(id)
handleRemove(){
if(this.props.userTeams.filter((el)=>{return el.user_id === this.state.userToRemove}).length > 1){
this.props.removeUser(this.state.userToRemove)
}else{
this.props.removeUser(-1)
}
this.setState({openConfirm: false})
}
discard(){
this.setState({openConfirm: false})
}
mod(id){
this.props.modUser(id)
}
showConfirm(id){
this.setState({
openConfirm: true,
userToRemove:id
})
}
render() {
const { t } = this.props
let rows = this.props.users.map((item,idx)=>{
return(
<Table.Row
......@@ -54,7 +69,7 @@ class UsersTable extends React.Component {
</Table.Cell>
<Table.Cell hidden={!this.props.manageUsers}>
<Popup
trigger={<Button circular icon={<Icon name='remove user' size='large'/>} onClick={()=>this.remove(item.user_id ? item.user_id : item.id)}/>}
trigger={<Button circular icon={<Icon name='remove user' size='large'/>} onClick={()=>this.showConfirm(item.user_id ? item.user_id : item.id)}/>}
content= {t("POPUP_DEL")}
/>
<Popup
......@@ -80,6 +95,13 @@ class UsersTable extends React.Component {
</Table.Header>
<Table.Body>
{rows}
<Confirm
open={this.state.openConfirm}
onCancel={this.discard.bind(this)}
onConfirm={this.handleRemove.bind(this)}
content="Sei sicuro di voler eliminare questo utente dal team?"
header="Conferma azione"
/>
</Table.Body>
</Table>
)
......
......@@ -54,9 +54,9 @@ class AddUserModal extends Component {
this.setState({teamName: team.name})
}
})
//get only users not already in this team
//get only users not already in this team and only of curUser's staff
let usrs = this.props.user_teams.filter((el)=>{
return el.team_id !== this.props.curTeam
return (el.team_id !== this.props.curTeam && el.idstaff === this.props.user.idstaff)
})
for(let i=0; i<usrs.length; i++){
for(let j=1; j<usrs.length; j++){
......@@ -127,7 +127,8 @@ class AddUserModal extends Component {
const mapStateToProps = (state)=>{
return{
user_teams: state.adminReducer.user_teams,
curTeam: state.modalReducer.toTeam
curTeam: state.modalReducer.toTeam,
user: state.user
}
}
const mapDispatchToProps = (dispatch) => {
......
import React, { Component, Fragment } from 'react'
import React, { Component } from 'react'
import { Modal, Button, Icon, Popup, Tab } from 'semantic-ui-react'
import PositiveMessage from '../components/PositiveMessage'
import NegativeMessage from '../components/ErrorMessage'
import EditUserForm from '../components/EditUserForm'
import EditPermissionsForm from '../components/EditPermissionsForm'
import {apolloFetch, apolloFetchNoAuth} from '../../store/apolloFetchUtils'
import {connect} from 'react-redux'
import {saveUserTeams} from '../../store/actions/AdministrationActions'
import { translate, Trans } from 'react-i18next'
import { escapeQuotes } from '../../store/functionUtils'
class EditUserParamsModal extends Component {
constructor(props){
......@@ -24,11 +27,17 @@ class EditUserParamsModal extends Component {
organization: this.props.toUser.organization,
link_web: this.props.toUser.web_site,
role_id: this.props.toUser.role_id,
newPerms: '',
roleModded: false,
old_password: '',
new_password: '',
activeIndex: 0
activeIndex: 0,
permissions: []
}
}
componentDidMount(){
this.setState({permissions: this.props.toUser.user_permissions})
}
nameChange(e){
this.setState({name: e.target.value, somethingModded: true})
}
......@@ -42,10 +51,15 @@ class EditUserParamsModal extends Component {
this.setState({organization: e.target.value, somethingModded: true})
}
linkWebChange(e){
this.setState({link_web: e.target.value, somethingModded: true})
this.setState({link_web: e.target.value, somethingModded: true, roleModded: true})
}
roleChange(e,data){
this.setState({role_id: data.value, somethingModded: true})
let newPerms = this.props.roles.find((role)=>{return role.id === data.value})
this.setState({
role_id: data.value,
permissions: newPerms.role_permissions,
roleModded: true,
somethingModded: true})
}
oldPassChange(e){
this.setState({old_password: e.target.value})
......@@ -56,42 +70,84 @@ class EditUserParamsModal extends Component {
modUser(){
let query = ``
if(this.state.old_password === '' && this.state.new_password === ''){
//password not modified
query = `
mutation modUser{
updateCaaUser(
id: ${this.props.toUser.user_id},
name: "${this.state.name}",
email: "${this.state.email}",
user: "${this.state.username}",
organization: "${this.state.organization}",
link_web: "${this.state.link_web}",
role_id: ${this.state.role_id}
){
id
//password not modified, check if role modified
if(this.state.roleModded){
query = `
mutation modUser{
updateCaaUser(
id: ${this.props.toUser.user_id},
name: "${this.state.name}",
email: "${this.state.email}",
user: "${this.state.username}",
organization: "${this.state.organization}",
link_web: "${this.state.link_web}",
role_id: ${this.state.role_id},
user_permissions: "${escapeQuotes(this.state.permissions)}"
){
id
}
}
`
}else{
query = `
mutation modUser{
updateCaaUser(
id: ${this.props.toUser.user_id},
name: "${this.state.name}",
email: "${this.state.email}",
user: "${this.state.username}",
organization: "${this.state.organization}",
link_web: "${this.state.link_web}"
){
id
}
}
`
}
`
}else{
//password to modify!
query = `
mutation modUser{
updateCaaUser(
id: ${this.props.toUser.user_id},
name: "${this.state.name}",
email: "${this.state.email}",
user: "${this.state.username}",
organization: "${this.state.organization}",
link_web: "${this.state.link_web}",
role_id: ${this.state.role_id},
old_password: "${this.state.old_password}",
new_password: "${this.state.new_password}"
){
id
//password to modify!, check if role modified
if(this.state.roleModded){
query = `
mutation modUser{
updateCaaUser(
id: ${this.props.toUser.user_id},
name: "${this.state.name}",
email: "${this.state.email}",
user: "${this.state.username}",
organization: "${this.state.organization}",
link_web: "${this.state.link_web}",
role_id: ${this.state.role_id},
old_password: "${this.state.old_password}",
new_password: "${this.state.new_password}",
role_id: ${this.state.role_id},
user_permissions: "${escapeQuotes(this.state.permissions)}"
){
id
}
}
`
}else{
query = `
mutation modUser{
updateCaaUser(
id: ${this.props.toUser.user_id},
name: "${this.state.name}",
email: "${this.state.email}",
user: "${this.state.username}",
organization: "${this.state.organization}",
link_web: "${this.state.link_web}",
role_id: ${this.state.role_id},
old_password: "${this.state.old_password}",
new_password: "${this.state.new_password}"
){
id
}
}
`
}
`
}
console.log(query);
this.setState({loading: true})
apolloFetch({query})
.then((data)=>{
......@@ -108,8 +164,62 @@ class EditUserParamsModal extends Component {
})
}
handleTabChange(e,{activeIndex}){
console.log(activeIndex);
this.setState({activeIndex})
this.setState({activeIndex, somethingModded: false})
}
handleChange(moddedKey){
// handler for permissions change
let tmp = this.state.permissions
Object.keys(this.state.permissions).forEach((key,index)=>{
if(key === moddedKey){
tmp[key] = !this.state.permissions[key]
this.setState({permissions : tmp, somethingModded: true})
}
})
}
updatePermissions(){
let query = `
mutation modUser{
updateCaaUser(
id: ${this.props.toUser.user_id},
user_permissions: "${escapeQuotes(this.state.permissions)}"
){
id
}
}
`
this.setState({loading: true})
apolloFetch({query})
.then((data)=>{
if(!data.hasOwnProperty("errors")){
//no errors returned, permissions updated correctly
this.setState({loading: false, error: false, updated: true})
this.props.saveUserTeamsToStore()
}else{
this.setState({loading: false, error: true, updated: false})
}
})
.catch((error)=>{
this.setState({loading: false, error: true, updated: false})
})
}
handleMod(which){
if(which === 0){
//launch params update
this.modUser()
}else{
//launch permissions update
this.updatePermissions()
}
}
closeMessage(which){
switch (which) {
case 1:
this.setState({updated: false})
break
case 2:
this.setState({error: false})
break
}
}
render(){
const editParamsForm = <EditUserForm
......@@ -129,10 +239,13 @@ class EditUserParamsModal extends Component {
newPassChange={()=>this.newPassChange.bind(this)}
toUser={this.props.toUser}
/>
const editPermissionsForm = <EditPermissionsForm permissions={this.props.toUser.user_permissions}/>
const editPermissionsForm = <EditPermissionsForm
permissions={this.state.permissions}
handlePermissionChange={this.handleChange.bind(this)}
/>
const panes=[
{menuItem: 'Parametri', render: ()=><Tab.Pane>{editParamsForm}</Tab.Pane>},
// {menuItem: 'Permessi', render: ()=><Tab.Pane>{editPermissionsForm}</Tab.Pane>}
{menuItem: 'Permessi', render: ()=><Tab.Pane>{editPermissionsForm}</Tab.Pane>}
]
return(
<Modal closeIcon="close" open={this.props.openModal} onClose={this.props.closeModal}>
......@@ -143,12 +256,12 @@ class EditUserParamsModal extends Component {
</Modal.Header>
<Modal.Content>
<Tab panes={panes} activeIndex={this.state.activeIndex} onTabChange={this.handleTabChange.bind(this)}/>
<PositiveMessage header="Tutto ok!" message="Utente modificato correttamente :)" hidden={!this.state.updated}/>
<NegativeMessage header="Errore!" message="Non è stato possibile modificare i parametri dell'utente" hidden={!this.state.error}/>
<PositiveMessage header="Tutto ok!" message="Utente modificato correttamente :)" hidden={!this.state.updated} onDismiss={()=>this.closeMessage(1)}/>
<NegativeMessage header="Errore!" message="Non è stato possibile modificare i parametri dell'utente" hidden={!this.state.error} onDismiss={()=>this.closeMessage(2)}/>
</Modal.Content>
<Modal.Actions>
<Button negative onClick={()=>this.props.closeModal()} loading={this.state.loading}>Chiudi</Button>
<Button positive onClick={()=>this.modUser()} loading={this.state.loading} disabled={!this.state.somethingModded}>Modifica</Button>
<Button positive onClick={()=>this.handleMod(this.state.activeIndex)} loading={this.state.loading} disabled={!this.state.somethingModded}>Modifica</Button>
</Modal.Actions>
</Modal>
)
......
......@@ -15,6 +15,7 @@ class ManageTeamModal extends Component {
super(props)
this.state={
error: false,
errorUserInOneTeam: false,
loading: false,
teamName: ''
}
......@@ -30,26 +31,43 @@ class ManageTeamModal extends Component {
}
removeUser(userteam_id){
//removes user from team
let query = `
mutation removeFromTeam{
deleteCaaUserTeam(id: ${userteam_id}){
id
if(userteam_id === -1){
this.setState({errorUserInOneTeam: true})
}else{
let query = `
mutation removeFromTeam{
deleteCaaUserTeam(id: ${userteam_id}){
id
}
}
}
`
this.setState({loading:true})
apolloFetch({ query })
.then((data) => {
if(data.hasOwnProperty("errors")){
this.setState({removed: false, loading: false, error: true});
}else{
this.setState({removed: true, loading: false, error: false});
this.props.saveUserTeamsToStore()
}
})
.catch((error) => {
`
this.setState({loading:true})
apolloFetch({ query })
.then((data) => {
if(data.hasOwnProperty("errors")){
this.setState({removed: false, loading: false, error: true});
})
}else{
this.setState({removed: true, loading: false, error: false});
this.props.saveUserTeamsToStore()
}
})
.catch((error) => {
this.setState({removed: false, loading: false, error: true});
})
}
}
closeMessage(which){
switch(which){
case 1:
this.setState({removed: false})
break
case 2:
this.setState({error: false})
break
case 3:
this.setState({errorUserInOneTeam: false})
break
}
}
render(){
return(
......@@ -64,8 +82,9 @@ class ManageTeamModal extends Component {
<ManageTeamTable
removeUser={this.removeUser.bind(this)}
/>
<PositiveMessage header="Tutto ok!" message="Utente eliminato correttamente dal team :)" hidden={!this.state.removed}/>
<NegativeMessage header="Errore!" message="Non è stato possibile rimuovere l'utente da questo team, riprova più tardi" hidden={!this.state.error}/>
<PositiveMessage header="Tutto ok!" message="Utente eliminato correttamente dal team :)" hidden={!this.state.removed} onDismiss={()=>this.closeMessage(1)}/>
<NegativeMessage header="Errore!" message="Non è stato possibile rimuovere l'utente da questo team, riprova più tardi" hidden={!this.state.error} onDismiss={()=>this.closeMessage(2)}/>
<NegativeMessage header="Errore!" message="Non è possibile rimuovere questo utente, appartiene solamente a questo team" hidden={!this.state.errorUserInOneTeam} onDismiss={()=>this.closeMessage(3)}/>
</Modal.Content>
<Modal.Actions>
<Button negative onClick={()=>this.props.closeModal()} loading={this.state.loading}>Chiudi</Button>
......
......@@ -42,6 +42,7 @@ class ManageTeamTable extends Component {
<Fragment>
<UsersTable
users={this.state.users}
userTeams={this.props.user_teams}
selectable={false}
manageUsers={true}
removeUser={this.remove.bind(this)}
......
......@@ -21,7 +21,8 @@ class RootComponent extends Component{
render(){
const { t } = this.props
let teamsLayout = this.props.teams.map((team, idx)=>{
//aggiungo tabella di questo team
if(this.props.user.idstaff === team.idstaff)
//aggiungo card di questo team, se fa parte dello staff dell'utente corrente
return(
<Card key={idx}>
<Card.Content>
......
import {apolloFetch, apolloFetchNoAuth} from '../apolloFetchUtils'
import {apolloFetchNoAuth} from '../apolloFetchUtils'
export function closeModal() {
return (dispatch) => {
......@@ -78,6 +78,7 @@ export function saveTeams(){
id
name
email
idstaff
}
}
}
......@@ -107,13 +108,13 @@ export function saveUserTeams(){
organization
web_site
role_id
idstaff
}
}
}
`
apolloFetchNoAuth({query})
.then((data)=>{
console.log(data);
data.data.user_teams.data.map((el)=>{
el.user_permissions = JSON.parse(el.user_permissions)
})
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -24,7 +24,6 @@ export function modalReducer(state = { }, action) {
});
return newState
case "OPEN_MODAL_EDIT_USER_PARAMS":
console.log(action.toUser);
newState = Object.assign({},state,{
openModal: true,
modalContent: "edit_user_params",
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755