mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
enable/disable group
This commit is contained in:
parent
40bf22279e
commit
c5f0501df2
@ -31,20 +31,20 @@ Application.Controllers.controller "GroupsController", ["$scope", 'groupsPromise
|
||||
##
|
||||
# Saves a new group / Update an existing group to the server (form validation callback)
|
||||
# @param data {Object} group name
|
||||
# @param [data] {number} group id, in case of update
|
||||
# @param [id] {number} group id, in case of update
|
||||
##
|
||||
$scope.saveGroup = (data, id) ->
|
||||
if id?
|
||||
Group.update {id: id}, { group: data }, (response) ->
|
||||
growl.success(_t('changes_successfully_saved'))
|
||||
growl.success(_t('group_form.changes_successfully_saved'))
|
||||
, (error) ->
|
||||
growl.error(_t('an_error_occurred_while_saving_changes'))
|
||||
growl.error(_t('group_form.an_error_occurred_while_saving_changes'))
|
||||
else
|
||||
Group.save { group: data }, (resp)->
|
||||
growl.success(_t('new_group_successfully_saved'))
|
||||
growl.success(_t('group_form.new_group_successfully_saved'))
|
||||
$scope.groups[$scope.groups.length-1].id = resp.id
|
||||
, (error) ->
|
||||
growl.error(_t('an_error_occurred_when_saving_the_new_group'))
|
||||
growl.error(_t('.group_forman_error_occurred_when_saving_the_new_group'))
|
||||
$scope.groups.splice($scope.groups.length-1, 1)
|
||||
|
||||
|
||||
@ -55,10 +55,24 @@ Application.Controllers.controller "GroupsController", ["$scope", 'groupsPromise
|
||||
##
|
||||
$scope.removeGroup = (index) ->
|
||||
Group.delete { id: $scope.groups[index].id }, (resp) ->
|
||||
growl.success(_t('group_successfully_deleted'))
|
||||
growl.success(_t('group_form.group_successfully_deleted'))
|
||||
$scope.groups.splice(index, 1)
|
||||
, (error) ->
|
||||
growl.error(_t('unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it'))
|
||||
growl.error(_t('group_form.unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it'))
|
||||
|
||||
|
||||
|
||||
##
|
||||
# Enable/disable the group at the specified index
|
||||
# @param index {number} group index in the $scope.groups array
|
||||
##
|
||||
$scope.toggleDisableGroup = (index) ->
|
||||
group = $scope.groups[index]
|
||||
Group.update {id: group.id}, { group: { disabled: !group.disabled } }, (response) ->
|
||||
$scope.groups[index] = response
|
||||
growl.success(_t('group_form.group_successfully_enabled_disabled', { STATUS: response.disabled }, 'messageformat'))
|
||||
, (error) ->
|
||||
growl.error(_t('group_form.unable_to_enable_disable_group', { STATUS: !group.disabled }, 'messageformat'))
|
||||
|
||||
|
||||
]
|
||||
|
@ -1,8 +1,8 @@
|
||||
<button type="button" class="btn btn-warning m-b m-t-lg" ng-click="addGroup()" translate>{{ 'add_a_group' }}</button>
|
||||
<button type="button" class="btn btn-warning m-b m-t-lg" ng-click="addGroup()" translate>{{ 'group_form.add_a_group' }}</button>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 80%;" translate>{{ 'group_name' }}</th>
|
||||
<th style="width: 80%;" translate>{{ 'group_form.group_name' }}</th>
|
||||
<th style="width: 20%"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -27,6 +27,10 @@
|
||||
<button class="btn btn-default" ng-click="rowform.$show()">
|
||||
<i class="fa fa-edit"></i> <span class="hidden-xs hidden-sm" translate>{{ 'edit' }}</span>
|
||||
</button>
|
||||
<button class="btn btn-default" ng-click="toggleDisableGroup($index)">
|
||||
<span ng-hide="group.disabled"><i class="fa fa-lock"></i> <span translate>{{ 'group_form.disable' }}</span></span>
|
||||
<span ng-show="group.disabled"><i class="fa fa-unlock"></i> <span translate>{{ 'group_form.enable' }}</span></span>
|
||||
</button>
|
||||
<button class="btn btn-danger" ng-click="removeGroup($index)">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</button>
|
||||
|
@ -40,6 +40,6 @@ class API::GroupsController < API::ApiController
|
||||
private
|
||||
|
||||
def group_params
|
||||
params.require(:group).permit(:name)
|
||||
params.require(:group).permit(:name, :disabled)
|
||||
end
|
||||
end
|
||||
|
@ -1 +1 @@
|
||||
json.extract! group, :id, :slug, :name
|
||||
json.extract! group, :id, :slug, :name, :disabled
|
||||
|
@ -396,14 +396,8 @@ en:
|
||||
this_may_take_a_while_please_wait: "Warning: this may take a while, please be patient."
|
||||
administrator_successfully_deleted: "Administrator successfully deleted."
|
||||
unable_to_delete_the_administrator: "Unable to delete the administrator."
|
||||
add_a_group: "Add a group"
|
||||
group_name: "Group name"
|
||||
changes_successfully_saved: "Changes successfully saved."
|
||||
an_error_occurred_while_saving_changes: "An error occurred when saving changes."
|
||||
new_group_successfully_saved: "New group successfully saved."
|
||||
an_error_occurred_when_saving_the_new_group: "An error occurred when saving the new group."
|
||||
group_successfully_deleted: "Group successfully deleted."
|
||||
unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it: "Unable to delete group because some users and/or groups are still linked to it."
|
||||
add_a_tag: "Add a tag"
|
||||
tag_name: "Tag name"
|
||||
new_tag_successfully_saved: "New tag successfully saved."
|
||||
@ -423,6 +417,19 @@ en:
|
||||
an_error_occurred_unable_to_delete_the_specified_provider: "An error occurred: unable to delete the specified provider."
|
||||
local_database: "Local database"
|
||||
o_auth2: "OAuth 2.0"
|
||||
group_form:
|
||||
add_a_group: "Add a group"
|
||||
group_name: "Group name"
|
||||
disable: "Disable"
|
||||
enable: "Enable"
|
||||
changes_successfully_saved: "Changes successfully saved."
|
||||
an_error_occurred_while_saving_changes: "An error occurred when saving changes."
|
||||
new_group_successfully_saved: "New group successfully saved."
|
||||
an_error_occurred_when_saving_the_new_group: "An error occurred when saving the new group."
|
||||
group_successfully_deleted: "Group successfully deleted."
|
||||
unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it: "Unable to delete group because some users and/or groups are still linked to it."
|
||||
group_successfully_enabled_disabled: "Group successfully {STATUS, select, true{disabled} other{enabled}}." # messageFormat interpolation
|
||||
unable_to_enable_disable_group: "Unable to {STATUS, select, true{disable} other{enable}} group." # messageFormat interpolation
|
||||
|
||||
members_new:
|
||||
# add a member
|
||||
|
@ -396,14 +396,8 @@ fr:
|
||||
this_may_take_a_while_please_wait: "Attention : ceci peut prendre un certain temps, merci de patienter."
|
||||
administrator_successfully_deleted: "L'administrateur a bien été supprimé."
|
||||
unable_to_delete_the_administrator: "L'administrateur n'a pas pu être supprimé."
|
||||
add_a_group: "Ajouter un groupe"
|
||||
group_name: "Nom du groupe"
|
||||
changes_successfully_saved: "Les modifications ont bien été enregistrées."
|
||||
an_error_occurred_while_saving_changes: "Une erreur est survenue lors de l'enregistrement des modifications."
|
||||
new_group_successfully_saved: "Le nouveau groupe a bien été enregistré."
|
||||
an_error_occurred_when_saving_the_new_group: "Une erreur est survenue lors de l'enregistrement du nouveau groupe."
|
||||
group_successfully_deleted: "Le groupe a bien été supprimé."
|
||||
unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it: "Le groupe n'a pas pu être supprimé car des utilisateurs et/ou des abonnements sont toujours associés à ce dernier."
|
||||
add_a_tag: "Ajouter une étiquette"
|
||||
tag_name: "Nom de l'étiquette"
|
||||
new_tag_successfully_saved: "La nouvelle étiquette a bien été enregistrée."
|
||||
@ -423,6 +417,19 @@ fr:
|
||||
an_error_occurred_unable_to_delete_the_specified_provider: "Une erreur est survenue : impossible de supprimer le fournisseur spécifié."
|
||||
local_database: "Base de données locale"
|
||||
o_auth2: "OAuth 2.0"
|
||||
group_form:
|
||||
add_a_group: "Ajouter un groupe"
|
||||
group_name: "Nom du groupe"
|
||||
disable: "Désactiver"
|
||||
enable: "Activer"
|
||||
changes_successfully_saved: "Les modifications ont bien été enregistrées."
|
||||
an_error_occurred_while_saving_changes: "Une erreur est survenue lors de l'enregistrement des modifications."
|
||||
new_group_successfully_saved: "Le nouveau groupe a bien été enregistré."
|
||||
an_error_occurred_when_saving_the_new_group: "Une erreur est survenue lors de l'enregistrement du nouveau groupe."
|
||||
group_successfully_deleted: "Le groupe a bien été supprimé."
|
||||
unable_to_delete_group_because_some_users_and_or_groups_are_still_linked_to_it: "Le groupe n'a pas pu être supprimé car des utilisateurs et/ou des abonnements sont toujours associés à ce dernier."
|
||||
group_successfully_enabled_disabled: "Le groupe a bien été {STATUS, select, true{désactivé} other{activé}}." # messageFormat interpolation
|
||||
unable_to_enable_disable_group: "Impossible {STATUS, select, true{de désactiver} other{d'activer}} le groupe." # messageFormat interpolation
|
||||
|
||||
members_new:
|
||||
# ajouter un membre
|
||||
|
5
db/migrate/20171005141522_add_disabled_to_group.rb
Normal file
5
db/migrate/20171005141522_add_disabled_to_group.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddDisabledToGroup < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :groups, :disabled, :boolean
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20171004135605) do
|
||||
ActiveRecord::Schema.define(version: 20171005141522) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@ -216,6 +216,7 @@ ActiveRecord::Schema.define(version: 20171004135605) do
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "slug", limit: 255
|
||||
t.boolean "disabled"
|
||||
end
|
||||
|
||||
add_index "groups", ["slug"], name: "index_groups_on_slug", unique: true, using: :btree
|
||||
|
Loading…
x
Reference in New Issue
Block a user