mirror of
https://github.com/strapi/strapi.git
synced 2025-08-31 12:23:05 +00:00
Fixes #3472
This commit is contained in:
parent
2537401ed9
commit
37ed213b6d
6
.gitignore
vendored
6
.gitignore
vendored
@ -125,3 +125,9 @@ packages/strapi-generate-new/files/public/
|
||||
############################
|
||||
|
||||
# *.cache
|
||||
|
||||
############################
|
||||
# Visual Studio Code
|
||||
############################
|
||||
|
||||
front-workspace.code-workspace
|
||||
|
@ -21,7 +21,6 @@
|
||||
"strapi-middleware-views": "3.0.0-beta.5",
|
||||
"strapi-plugin-content-manager": "3.0.0-beta.5",
|
||||
"strapi-plugin-content-type-builder": "3.0.0-beta.5",
|
||||
"strapi-plugin-documentation": "3.0.0-beta.5",
|
||||
"strapi-plugin-email": "3.0.0-beta.5",
|
||||
"strapi-plugin-graphql": "3.0.0-beta.5",
|
||||
"strapi-plugin-settings-manager": "3.0.0-beta.5",
|
||||
|
@ -201,9 +201,7 @@ module.exports = {
|
||||
`environments.${env}.request.router.prefix`,
|
||||
null
|
||||
),
|
||||
validations: {
|
||||
required: true,
|
||||
},
|
||||
validations: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -1,64 +1,95 @@
|
||||
/**
|
||||
*
|
||||
* Controller
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Controller
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { get, map, some } from 'lodash';
|
||||
import cn from 'classnames';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import pluginId from '../../pluginId';
|
||||
|
||||
import InputCheckbox from '../InputCheckboxPlugin';
|
||||
import styles from './styles.scss';
|
||||
|
||||
class Controller extends React.Component {
|
||||
state = { inputSelected: '', checked: false };
|
||||
state = { inputSelected: '' };
|
||||
|
||||
setNewInputSelected = (name) => {
|
||||
this.setState({ inputSelected: name, checked: false });
|
||||
}
|
||||
setNewInputSelected = name => {
|
||||
this.setState({ inputSelected: name });
|
||||
};
|
||||
|
||||
handleChange = () => {
|
||||
this.setState({ checked: !this.state.checked });
|
||||
this.context.selectAllActions(`${this.props.inputNamePath}.controllers.${this.props.name}`, !this.isAllActionsSelected());
|
||||
}
|
||||
this.context.selectAllActions(
|
||||
`${this.props.inputNamePath}.controllers.${this.props.name}`,
|
||||
!this.areAllActionsSelected()
|
||||
);
|
||||
};
|
||||
|
||||
isAllActionsSelected = () => !some(this.props.actions, ['enabled', false]);
|
||||
hasSomeActionsSelected = () => {
|
||||
const { actions } = this.props;
|
||||
|
||||
return Object.keys(actions).some(
|
||||
action => actions[action].enabled === true
|
||||
);
|
||||
};
|
||||
|
||||
areAllActionsSelected = () => {
|
||||
const { actions } = this.props;
|
||||
|
||||
return Object.keys(actions).every(
|
||||
action => actions[action].enabled === true
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const labelId = this.areAllActionsSelected() ? 'unselectAll' : 'selectAll';
|
||||
|
||||
return (
|
||||
<div className={styles.controller}>
|
||||
<div className={styles.controllerHeader}>
|
||||
<div>{this.props.name}</div>
|
||||
<div className={styles.separator}></div>
|
||||
<div className={styles.separator} />
|
||||
<div>
|
||||
<div className={cn(styles.inputCheckbox)}>
|
||||
<div className="form-check">
|
||||
<label className={cn('form-check-label', styles.label, this.state.checked ? styles.checked : '')} htmlFor={this.props.name}>
|
||||
<label
|
||||
className={cn(
|
||||
'form-check-label',
|
||||
styles.label,
|
||||
this.areAllActionsSelected() && styles.checked,
|
||||
!this.areAllActionsSelected() &&
|
||||
this.hasSomeActionsSelected() &&
|
||||
styles.someChecked
|
||||
)}
|
||||
htmlFor={this.props.name}
|
||||
>
|
||||
<input
|
||||
className="form-check-input"
|
||||
checked={this.state.checked}
|
||||
checked={this.areAllActionsSelected()}
|
||||
id={this.props.name}
|
||||
name={this.props.name}
|
||||
onChange={this.handleChange}
|
||||
type="checkbox"
|
||||
/>
|
||||
<FormattedMessage id="users-permissions.Controller.selectAll" />
|
||||
<FormattedMessage id={`${pluginId}.Controller.${labelId}`} />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="row">
|
||||
{map(Object.keys(this.props.actions).sort(), (actionKey) => (
|
||||
{map(Object.keys(this.props.actions).sort(), actionKey => (
|
||||
<InputCheckbox
|
||||
inputSelected={this.state.inputSelected}
|
||||
isOpen={this.props.isOpen}
|
||||
key={actionKey}
|
||||
label={actionKey}
|
||||
name={`${this.props.inputNamePath}.controllers.${this.props.name}.${actionKey}.enabled`}
|
||||
name={`${this.props.inputNamePath}.controllers.${
|
||||
this.props.name
|
||||
}.${actionKey}.enabled`}
|
||||
setNewInputSelected={this.setNewInputSelected}
|
||||
value={get(this.props.actions[actionKey], 'enabled')}
|
||||
/>
|
||||
|
@ -11,6 +11,17 @@
|
||||
|
||||
}
|
||||
}
|
||||
.someChecked {
|
||||
&:after {
|
||||
content: '\f068';
|
||||
position: absolute;
|
||||
top: 0px; left: 3px;
|
||||
font-size: 10px;
|
||||
font-family: 'FontAwesome';
|
||||
font-weight: 100;
|
||||
color: #1C5DE7;
|
||||
}
|
||||
}
|
||||
|
||||
.controller {
|
||||
padding: 1px 43px 0 28px;
|
||||
@ -67,3 +78,4 @@
|
||||
margin-left: 15px;
|
||||
background-color: #F6F6F6;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
/**
|
||||
*
|
||||
* Plugins
|
||||
*
|
||||
*/
|
||||
*
|
||||
* Plugins
|
||||
*
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
@ -17,7 +17,7 @@ import styles from './styles.scss';
|
||||
class Plugins extends React.Component {
|
||||
state = { pluginSelected: '' };
|
||||
|
||||
changePluginSelected = (name) => this.setState({ pluginSelected: name });
|
||||
changePluginSelected = name => this.setState({ pluginSelected: name });
|
||||
|
||||
render() {
|
||||
return (
|
||||
@ -31,8 +31,13 @@ class Plugins extends React.Component {
|
||||
<FormattedMessage id="users-permissions.Plugins.header.description" />
|
||||
</div>
|
||||
</div>
|
||||
<div className={cn(styles.pluginsContainer, !has(this.props.plugins, 'application') && styles.pluginsGradient)}>
|
||||
{map(Object.keys(this.props.plugins).sort(), (plugin) => (
|
||||
<div
|
||||
className={cn(
|
||||
styles.pluginsContainer,
|
||||
!has(this.props.plugins, 'application') && styles.pluginsGradient
|
||||
)}
|
||||
>
|
||||
{map(Object.keys(this.props.plugins).sort(), plugin => (
|
||||
<Plugin
|
||||
changePluginSelected={this.changePluginSelected}
|
||||
key={plugin}
|
||||
|
@ -48,6 +48,7 @@
|
||||
"BoundRoute.title": "Bound route to",
|
||||
"Controller.input.label": "{label} ",
|
||||
"Controller.selectAll": "Select all",
|
||||
"Controller.unselectAll": "Unselect all",
|
||||
"EditForm.inputSelect.description.role": "It will attach the new authenticated user to the selected role.",
|
||||
"EditForm.inputSelect.durations.description": "Number of hours during which the user can't subscribe.",
|
||||
"EditForm.inputSelect.durations.label": "Duration",
|
||||
|
@ -48,6 +48,7 @@
|
||||
"BoundRoute.title": "Route associée à",
|
||||
"Controller.input.label": "{label} ",
|
||||
"Controller.selectAll": "Tout cocher",
|
||||
"Controller.unselectAll": "Tout décocher",
|
||||
"EditForm.inputSelect.description.role": "Choisissez le rôle qui sera lié aux utilisateurs lors de leur enregistrement.",
|
||||
"EditForm.inputSelect.durations.description": "Nombre d'heure pendant lesquelles un utilisateur ne peut pas s'inscrire.",
|
||||
"EditForm.inputSelect.durations.label": "Durée",
|
||||
|
Loading…
x
Reference in New Issue
Block a user