From c813a05329ad7cf5b5f187bc754a521dad6e2fb2 Mon Sep 17 00:00:00 2001 From: Heiko Bernloehr Date: Tue, 7 Mar 2017 12:40:19 +0100 Subject: Initial helpers. --- app/helpers/admin/communities_helper.rb | 20 ++++++++ app/helpers/admin/identities_helper.rb | 20 ++++++++ app/helpers/admin/organizations_helper.rb | 20 ++++++++ app/helpers/admin/participants_helper.rb | 80 +++++++++++++++++++++++++++++++ app/helpers/admin/ressources_helper.rb | 27 +++++++++++ app/helpers/application_helper.rb | 30 ++++++++++++ app/helpers/configs_helper.rb | 2 + app/helpers/events_helper.rb | 20 ++++++++ app/helpers/filter_api.rb | 22 +++++++++ app/helpers/memberships_helper.rb | 20 ++++++++ app/helpers/messages_helper.rb | 20 ++++++++ app/helpers/queue_helper.rb | 20 ++++++++ app/helpers/subparticipants_helper.rb | 19 ++++++++ 13 files changed, 320 insertions(+) create mode 100644 app/helpers/admin/communities_helper.rb create mode 100644 app/helpers/admin/identities_helper.rb create mode 100644 app/helpers/admin/organizations_helper.rb create mode 100644 app/helpers/admin/participants_helper.rb create mode 100644 app/helpers/admin/ressources_helper.rb create mode 100644 app/helpers/configs_helper.rb create mode 100644 app/helpers/events_helper.rb create mode 100644 app/helpers/filter_api.rb create mode 100644 app/helpers/memberships_helper.rb create mode 100644 app/helpers/messages_helper.rb create mode 100644 app/helpers/queue_helper.rb create mode 100644 app/helpers/subparticipants_helper.rb diff --git a/app/helpers/admin/communities_helper.rb b/app/helpers/admin/communities_helper.rb new file mode 100644 index 0000000..0cbf0c1 --- /dev/null +++ b/app/helpers/admin/communities_helper.rb @@ -0,0 +1,20 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +module Admin::CommunitiesHelper +end diff --git a/app/helpers/admin/identities_helper.rb b/app/helpers/admin/identities_helper.rb new file mode 100644 index 0000000..7717409 --- /dev/null +++ b/app/helpers/admin/identities_helper.rb @@ -0,0 +1,20 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +module Admin::IdentitiesHelper +end diff --git a/app/helpers/admin/organizations_helper.rb b/app/helpers/admin/organizations_helper.rb new file mode 100644 index 0000000..ab18c72 --- /dev/null +++ b/app/helpers/admin/organizations_helper.rb @@ -0,0 +1,20 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +module Admin::OrganizationsHelper +end diff --git a/app/helpers/admin/participants_helper.rb b/app/helpers/admin/participants_helper.rb new file mode 100644 index 0000000..6d90ed5 --- /dev/null +++ b/app/helpers/admin/participants_helper.rb @@ -0,0 +1,80 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +module Admin::ParticipantsHelper + + @queryparams = [[:list_anonymous,:anonymous], [:action_buttons, :actionbuttons]] + + # adds an empty identity object to the p.identities collection. This object + # ist still not saved. This collection is reused in the form.fields_for method. + # (form.fields_for :identities ...) + def setup_participant(participant) + returning(participant) do |p| + p.identities.build + p.communities.build + end + end + + def button_to_reset(participant, list_anonymous, action_buttons) + button_to_reset = "button_to 'Reset', reset_admin_participant_path(:id => participant,#{(list_anonymous)?":anonymous => true":":anonymous => false"}" + button_to_reset += ", #{(action_buttons)?":actionbuttons => true":":actionbuttons => false"})" + button_to_reset += ", :title => 'All messages and events of \"#{h participant.name}\" participant will be deleted. #{(ECS_CONFIG["admin"]["confirm_actions"])?"":"There will be no confirmation !"}'" + button_to_reset += ", #{(action_buttons)?":disabled => false":":disabled => true"}" + button_to_reset += ", :confirm => 'Are you sure?'" if ECS_CONFIG["admin"]["confirm_actions"] + eval button_to_reset + end + + def button_to_delete(participant, list_anonymous, action_buttons) + button_to_delete = "button_to 'Delete', admin_participant_path(:id => participant,#{(list_anonymous)?":anonymous => true":":anonymous => false"}" + button_to_delete += ", #{(action_buttons)?":actionbuttons => true":":actionbuttons => false"})" + button_to_delete +=", :method => :delete" + button_to_delete +=", :title => 'The \"#{h participant.name}\" participant will be deleted. #{(ECS_CONFIG["admin"]["confirm_actions"])?"":"There will be no confirmation !"}'" + button_to_delete += ", #{(action_buttons)?":disabled => false":":disabled => true"}" + button_to_delete += ", :confirm => 'Are you sure?'" if ECS_CONFIG["admin"]["confirm_actions"] + eval button_to_delete + end + + def link_to_actions_toggle_on_off(list_anonymous, action_buttons) + Rails.logger.info "Admin::ParticipantsHelper#link_to_actions_toggle_on_off actionbuttons = #{action_buttons}" + link = "link_to #{(action_buttons)?'\'off\'':'\'on\''}, admin_participants_path(#{(list_anonymous)?":anonymous => true":":anonymous => false"}" + link +=", #{(action_buttons)?":actionbuttons => false":":actionbuttons => true"})" + unless action_buttons + session[:link_to_actions_toggle_on_off] = false + end + if not session[:link_to_actions_toggle_on_off] and action_buttons + session[:link_to_actions_toggle_on_off] = true + unless ECS_CONFIG["admin"]["confirm_actions"] + flash.now[:notice] = "Action buttons operate in NON CONFIRMATION mode, .i.e. pressing a delete or reset button just do its job without any confirmation. You have been warned ! To change this behaviour, just set \"admin->confirm_actions\" to \"true\" in \"config/ecs_config.yml\"." + end + end + eval link + end + + def link_to_anonymous_toggle_on_off(list_anonymous, action_buttons) + end + + def toggle_query_param(queryparam) + end + + def link_to_toggle_on_off(ontext, offtext, list_anonymous, action_buttons) + #link = "link_to #{(action_buttons)?\'offtext\':\'ontext\'}, admin_participants_path(#{(list_anonymous)?":anonymous => true":":anonymous => false"}" + #link +=", #{(action_buttons)?":actionbuttons => false":":actionbuttons => true"})" + #eval link + end + +end diff --git a/app/helpers/admin/ressources_helper.rb b/app/helpers/admin/ressources_helper.rb new file mode 100644 index 0000000..29b64dc --- /dev/null +++ b/app/helpers/admin/ressources_helper.rb @@ -0,0 +1,27 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +module Admin::RessourcesHelper + + def setup_ressource(ressource) + returning(ressource) do |r| + # setup more + end + end + +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..7721625 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,32 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +# Methods added to this helper will be available to all templates in the application. module ApplicationHelper + + # return a collection of all communities with an empty one appended. + def setup_community_collection + return Community.find(:all) << Community.new + end + + # returns the maximum line width of a text with "\r\n" lineendings. + def max_text_width(text) + text.split(/\r\n/).map {|t| t.length}.max + end + end diff --git a/app/helpers/configs_helper.rb b/app/helpers/configs_helper.rb new file mode 100644 index 0000000..5cac46f --- /dev/null +++ b/app/helpers/configs_helper.rb @@ -0,0 +1,2 @@ +module ConfigsHelper +end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb new file mode 100644 index 0000000..754d6d5 --- /dev/null +++ b/app/helpers/events_helper.rb @@ -0,0 +1,20 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +module EventsHelper +end diff --git a/app/helpers/filter_api.rb b/app/helpers/filter_api.rb new file mode 100644 index 0000000..b747f22 --- /dev/null +++ b/app/helpers/filter_api.rb @@ -0,0 +1,22 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +class FilterApi + attr_accessor :params, :record +end + diff --git a/app/helpers/memberships_helper.rb b/app/helpers/memberships_helper.rb new file mode 100644 index 0000000..ad61b08 --- /dev/null +++ b/app/helpers/memberships_helper.rb @@ -0,0 +1,20 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +module MembershipsHelper +end diff --git a/app/helpers/messages_helper.rb b/app/helpers/messages_helper.rb new file mode 100644 index 0000000..9c923f8 --- /dev/null +++ b/app/helpers/messages_helper.rb @@ -0,0 +1,20 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +module MessagesHelper +end diff --git a/app/helpers/queue_helper.rb b/app/helpers/queue_helper.rb new file mode 100644 index 0000000..6a09608 --- /dev/null +++ b/app/helpers/queue_helper.rb @@ -0,0 +1,20 @@ +# Copyright (C) 2007, 2008, 2009, 2010 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + + +module QueueHelper +end diff --git a/app/helpers/subparticipants_helper.rb b/app/helpers/subparticipants_helper.rb new file mode 100644 index 0000000..8a08bcd --- /dev/null +++ b/app/helpers/subparticipants_helper.rb @@ -0,0 +1,19 @@ +# Copyright (C) 2014 Heiko Bernloehr (FreeIT.de). +# +# This file is part of ECS. +# +# ECS is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# ECS is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with ECS. If not, see . + +module SubparticipantsHelper +end -- cgit v1.2.3