From 3099e740ca5897f5c7379f851e17f473f88436a3 Mon Sep 17 00:00:00 2001 From: Julius Date: Sat, 21 Dec 2013 22:52:39 +0100 Subject: [PATCH 01/16] Do not escape mailing list links in message form --- app/views/messages/new.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/messages/new.haml b/app/views/messages/new.haml index 8541b996..21dc2843 100644 --- a/app/views/messages/new.haml +++ b/app/views/messages/new.haml @@ -25,7 +25,7 @@ - if FoodsoftConfig[:mailing_list].blank? = f.input :sent_to_all, :as => :boolean - else - %b= t '.list.desc', list: mail_to(FoodsoftConfig[:mailing_list]) + %b= t('.list.desc', list: mail_to(FoodsoftConfig[:mailing_list])).html_safe %br/ %small{:style => "color:grey"} = t '.list.subscribe_msg' @@ -33,7 +33,7 @@ - if FoodsoftConfig[:mailing_list_subscribe].blank? = t '.list.subscribe', link: link_to(t('.list.wiki'), wiki_page_path('MailingListe')) - else - = t '.list.mail', email: mail_to(FoodsoftConfig[:mailing_list_subscribe]) + = t('.list.mail', email: mail_to(FoodsoftConfig[:mailing_list_subscribe])).html_safe #recipients = f.input :recipient_tokens, :input_html => { 'data-pre' => User.find_all_by_id(@message.recipients_ids).map { |u| u.token_attributes }.to_json } From df9cff0eee9eec175358d7a2bc3388306e11ca33 Mon Sep 17 00:00:00 2001 From: wvengen Date: Sun, 22 Dec 2013 01:59:33 +0100 Subject: [PATCH 02/16] Do not escape mailing list wiki link in the message form (foodcoops#227) --- app/views/messages/new.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/messages/new.haml b/app/views/messages/new.haml index 7fdb3151..577eef16 100644 --- a/app/views/messages/new.haml +++ b/app/views/messages/new.haml @@ -31,7 +31,7 @@ = t '.list.subscribe_msg' %br/ - if FoodsoftConfig[:mailing_list_subscribe].blank? - = t '.list.subscribe', link: link_to(t('.list.wiki'), wiki_page_path('MailingListe')) + = t('.list.subscribe', link: link_to(t('.list.wiki'), wiki_page_path('MailingListe'))).html_safe - else = t('.list.mail', email: mail_to(FoodsoftConfig[:mailing_list_subscribe])).html_safe From 496a2504959c7752264bdc9d2283511f7a76c2dd Mon Sep 17 00:00:00 2001 From: Julius Date: Sun, 22 Dec 2013 12:17:02 +0100 Subject: [PATCH 03/16] Rescue on WikiCloth exception --- config/locales/de.yml | 1 + config/locales/en.yml | 1 + lib/foodsoft_wiki/app/helpers/pages_helper.rb | 2 ++ 3 files changed, 4 insertions(+) diff --git a/config/locales/de.yml b/config/locales/de.yml index 146a827f..b2bd925d 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1167,6 +1167,7 @@ de: title_list: Seiten-Liste body: title_toc: Inhalt + wikicloth_exception: Entschuldigung, ein Fehler ist aufgetreten. Möglicherweise ist ein ungewöhnlicher Text die Ursache. Bearbeiten der Seite kann helfen, diesen Fehler zu beseitigen. create: notice: Seite wurde angelegt cshow: diff --git a/config/locales/en.yml b/config/locales/en.yml index 9d6005bc..663d9398 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1171,6 +1171,7 @@ en: title_list: List of pages body: title_toc: Content + wikicloth_exception: An error occured. Sorry for that. It might be that the wiki syntax has been used in an unusual way. Please try to edit the page to get rid of this error. create: notice: Page was created cshow: diff --git a/lib/foodsoft_wiki/app/helpers/pages_helper.rb b/lib/foodsoft_wiki/app/helpers/pages_helper.rb index 552791f3..ce3eb246 100644 --- a/lib/foodsoft_wiki/app/helpers/pages_helper.rb +++ b/lib/foodsoft_wiki/app/helpers/pages_helper.rb @@ -4,6 +4,8 @@ module PagesHelper def wikified_body(body, title = nil) render_opts = {:locale => I18n.locale} # workaround for wikicloth 0.8.0 https://github.com/nricciar/wikicloth/pull/59 WikiCloth.new({:data => body+"\n", :link_handler => Wikilink.new, :params => {:referer => title}}).to_html(render_opts).html_safe + rescue + t('.wikicloth_exception').html_safe # try the following with line breaks: === one === == two == = three = end def link_to_wikipage(page, text = nil) From 3e1d561a5ecabc42440454efec045c367d1f9bb6 Mon Sep 17 00:00:00 2001 From: wvengen Date: Sun, 22 Dec 2013 13:28:33 +0100 Subject: [PATCH 04/16] fix user form field order and autocompletion --- app/views/admin/users/_form.html.haml | 2 +- app/views/home/profile.html.haml | 2 +- app/views/shared/_user_form_fields.html.haml | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/views/admin/users/_form.html.haml b/app/views/admin/users/_form.html.haml index eeb70abf..4fb28547 100644 --- a/app/views/admin/users/_form.html.haml +++ b/app/views/admin/users/_form.html.haml @@ -1,5 +1,5 @@ = simple_form_for([:admin, @user]) do |f| - = render 'shared/user_form_fields', f: f + = render 'shared/user_form_fields', f: f, password_autocomplete: false .form-actions = f.submit = link_to t('ui.or_cancel'), :back diff --git a/app/views/home/profile.html.haml b/app/views/home/profile.html.haml index 0b0364a1..0b164d73 100644 --- a/app/views/home/profile.html.haml +++ b/app/views/home/profile.html.haml @@ -6,7 +6,7 @@ = h(t('.user.title', user: show_user)) %small= t '.user.since', when: distance_of_time_in_words(Time.now, @current_user.created_on) = simple_form_for(@current_user, :url => update_profile_path) do |f| - = render :partial => 'shared/user_form_fields', :locals => {:f => f} + = render :partial => 'shared/user_form_fields', :locals => {:f => f, :password_autocomplete => false} .form-actions = submit_tag t('ui.save'), class: 'btn' .span5 diff --git a/app/views/shared/_user_form_fields.html.haml b/app/views/shared/_user_form_fields.html.haml index 56701874..bb9b9fa1 100644 --- a/app/views/shared/_user_form_fields.html.haml +++ b/app/views/shared/_user_form_fields.html.haml @@ -1,12 +1,15 @@ -- if FoodsoftConfig[:use_nick] - -# use_nil option to user model validators break required mark - = f.input :nick, required: true = f.input :first_name = f.input :last_name = f.input :email +-# need :required because :use_nil option on user model validators break the required mark += f.input :nick, required: true if FoodsoftConfig[:use_nick] +-# you can disable password autocompletion by passing `password_autocomplete: false` to this partial +-# see also https://github.com/foodcoops/foodsoft/wiki/Form-autocompletion +- password_autocomplete = nil unless defined?(:password_autocomplete) +- passwd_opts = (password_autocomplete.nil? ? {} : {autocomplete: password_autocomplete ? 'on' : 'off'}) += f.input :password, :required => f.object.new_record?, input_html: passwd_opts += f.input :password_confirmation, :required => f.object.new_record?, input_html: passwd_opts = f.input :phone -= f.input :password, :required => f.object.new_record? -= f.input :password_confirmation = f.simple_fields_for :settings_attributes do |s| = s.simple_fields_for :profile, defaults: { inline_label: true } do |profile| From cee96915f99ad09230820cbd6bb2608befd41e62 Mon Sep 17 00:00:00 2001 From: wvengen Date: Sun, 22 Dec 2013 13:58:49 +0100 Subject: [PATCH 05/16] remove unused redirect_to functionality --- app/controllers/application_controller.rb | 14 +------------- app/controllers/invites_controller.rb | 2 +- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9c77fe48..9a5de547 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base helper_method :available_locales protect_from_forgery - before_filter :select_foodcoop, :authenticate, :store_controller, :items_per_page, :set_redirect_to + before_filter :select_foodcoop, :authenticate, :store_controller, :items_per_page after_filter :remove_controller @@ -128,18 +128,6 @@ class ApplicationController < ActionController::Base end end - def set_redirect_to - session[:redirect_to] = params[:redirect_to] if params[:redirect_to] - end - - def back_or_default_path(default = root_path) - if session[:redirect_to].present? - default = session[:redirect_to] - session[:redirect_to] = nil - end - default - end - # Always stay in foodcoop url scope def default_url_options(options = {}) {foodcoop: FoodsoftConfig.scope} diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index f301156a..440db16a 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -14,7 +14,7 @@ class InvitesController < ApplicationController respond_to do |format| format.html do - redirect_to back_or_default_path, notice: I18n.t('invites.success') + redirect_to root_path, notice: I18n.t('invites.success') end format.js { render layout: false } end From 7ef6832ab3708744b8ebf85778ba6f236524c426 Mon Sep 17 00:00:00 2001 From: wvengen Date: Sun, 22 Dec 2013 14:20:25 +0100 Subject: [PATCH 06/16] fix invite authentication --- app/controllers/application_controller.rb | 4 ++-- app/controllers/invites_controller.rb | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9a5de547..dcc0f298 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -80,8 +80,8 @@ class ApplicationController < ActionController::Base # checks if the current_user is member of given group. # if fails the user will redirected to startpage - def authenticate_membership_or_admin - @group = Group.find(params[:id]) + def authenticate_membership_or_admin(group_id = params[:id]) + @group = Group.find(group_id) unless @group.member?(@current_user) or @current_user.role_admin? redirect_to root_path, alert: I18n.t('application.controller.error_members_only') end diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 440db16a..553e4398 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -1,13 +1,13 @@ class InvitesController < ApplicationController - before_filter :authenticate_membership_or_admin, :only => [:new] - #TODO: authorize also for create action. + before_filter :authenticate_membership_or_admin_for_invites def new @invite = Invite.new(:user => @current_user, :group => @group) end def create + authenticate_membership_or_admin params[:invite][:group_id] @invite = Invite.new(params[:invite]) if @invite.save Mailer.invite(@invite).deliver @@ -23,4 +23,10 @@ class InvitesController < ApplicationController render action: :new end end + + protected + + def authenticate_membership_or_admin_for_invites + authenticate_membership_or_admin((params[:invite][:group_id] rescue params[:id])) + end end From 42e983f7ee4be4a61c8341115cb2ba95b760b5ac Mon Sep 17 00:00:00 2001 From: Julius Date: Sun, 22 Dec 2013 18:09:40 +0100 Subject: [PATCH 07/16] Move html markup of WikiCloth exception from locales to controller --- config/locales/de.yml | 2 +- config/locales/en.yml | 2 +- lib/foodsoft_wiki/app/helpers/pages_helper.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index b2bd925d..9510b7d3 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1167,7 +1167,7 @@ de: title_list: Seiten-Liste body: title_toc: Inhalt - wikicloth_exception: Entschuldigung, ein Fehler ist aufgetreten. Möglicherweise ist ein ungewöhnlicher Text die Ursache. Bearbeiten der Seite kann helfen, diesen Fehler zu beseitigen. + wikicloth_exception: Entschuldigung, ein Fehler ist aufgetreten. Möglicherweise ist ein ungewöhnlicher Text die Ursache. Bearbeiten der Seite kann helfen, diesen Fehler zu beseitigen. create: notice: Seite wurde angelegt cshow: diff --git a/config/locales/en.yml b/config/locales/en.yml index 663d9398..210ad10c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1171,7 +1171,7 @@ en: title_list: List of pages body: title_toc: Content - wikicloth_exception: An error occured. Sorry for that. It might be that the wiki syntax has been used in an unusual way. Please try to edit the page to get rid of this error. + wikicloth_exception: An error occured. Sorry for that. It might be that the wiki syntax has been used in an unusual way. Please try to edit the page to get rid of this error. create: notice: Page was created cshow: diff --git a/lib/foodsoft_wiki/app/helpers/pages_helper.rb b/lib/foodsoft_wiki/app/helpers/pages_helper.rb index ce3eb246..bd6e6078 100644 --- a/lib/foodsoft_wiki/app/helpers/pages_helper.rb +++ b/lib/foodsoft_wiki/app/helpers/pages_helper.rb @@ -5,7 +5,7 @@ module PagesHelper render_opts = {:locale => I18n.locale} # workaround for wikicloth 0.8.0 https://github.com/nricciar/wikicloth/pull/59 WikiCloth.new({:data => body+"\n", :link_handler => Wikilink.new, :params => {:referer => title}}).to_html(render_opts).html_safe rescue - t('.wikicloth_exception').html_safe # try the following with line breaks: === one === == two == = three = + "#{t '.wikicloth_exception'}".html_safe # try the following with line breaks: === one === == two == = three = end def link_to_wikipage(page, text = nil) From 53e611c1c0e880d82aaae5269eeb6b6190eeb895 Mon Sep 17 00:00:00 2001 From: Julius Date: Sun, 22 Dec 2013 18:26:28 +0100 Subject: [PATCH 08/16] Allow browser to store new password after change --- app/assets/javascripts/application.js | 9 +++++++++ app/views/shared/_user_form_fields.html.haml | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 0517c896..d6f74838 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -35,6 +35,15 @@ $.fn.extend({ // Load following statements, when DOM is ready $(function() { + // The autocomplete attribute is used for both autocompletion and storing + // for passwords, it's nice to store it when editing one's own profile, + // but never autocomplete. + // This is only implemented for passwords. + $('input[type="password"][autocomplete="off"][data-store="on"]').each(function() { + $(this).on('change', function() { + $(this).removeAttr('autocomplete'); + }); + }); // Show/Hide a specific DOM element $(document).on('click', 'a[data-toggle-this]', function() { diff --git a/app/views/shared/_user_form_fields.html.haml b/app/views/shared/_user_form_fields.html.haml index bb9b9fa1..bf0af9bc 100644 --- a/app/views/shared/_user_form_fields.html.haml +++ b/app/views/shared/_user_form_fields.html.haml @@ -6,7 +6,7 @@ -# you can disable password autocompletion by passing `password_autocomplete: false` to this partial -# see also https://github.com/foodcoops/foodsoft/wiki/Form-autocompletion - password_autocomplete = nil unless defined?(:password_autocomplete) -- passwd_opts = (password_autocomplete.nil? ? {} : {autocomplete: password_autocomplete ? 'on' : 'off'}) +- passwd_opts = (password_autocomplete.nil? ? {} : {autocomplete: password_autocomplete ? 'on' : 'off', data: {store: 'on'}}) = f.input :password, :required => f.object.new_record?, input_html: passwd_opts = f.input :password_confirmation, :required => f.object.new_record?, input_html: passwd_opts = f.input :phone From d071c5bba824d46c59347fcc7054e7706b955d87 Mon Sep 17 00:00:00 2001 From: wvengen Date: Sun, 22 Dec 2013 23:21:02 +0100 Subject: [PATCH 09/16] fix user search --- app/models/user.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 19ea452c..f04d2714 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -73,8 +73,15 @@ class User < ActiveRecord::Base # search by (nick)name def self.natural_search(q) - # we always use both nick and name, to make sure a user is found - where("CONCAT(first_name, CONCAT(' ', last_name)) LIKE :q OR nick LIKE :q", q: "%#{q}%") + q = q.strip + users = User.arel_table + # full string as nickname + match_nick = users[:nick].matches("%#{q}%") + # or each word matches either first or last name + match_name = q.split.map do |a| + users[:first_name].matches("%#{a}%").or users[:last_name].matches("%#{a}%") + end.reduce(:and) + User.where(match_nick.or match_name) end def locale From ed228c4bd7a5e15a6fc65eb95bc067e3fd8f076d Mon Sep 17 00:00:00 2001 From: Julius Date: Sun, 22 Dec 2013 23:21:14 +0100 Subject: [PATCH 10/16] Allow control of password autocomplete by flag --- app/helpers/application_helper.rb | 10 ++++++++++ app/views/home/profile.html.haml | 2 +- app/views/shared/_user_form_fields.html.haml | 9 +++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ef516a67..fab0bde0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -203,5 +203,15 @@ module ApplicationHelper :title => I18n.t('helpers.application.write_message') end end + + # provide input_html for password autocompletion + def autocomplete_flag_to_password_html(password_autocomplete) + case password_autocomplete + when true then {autocomplete: 'on'} + when false then {autocomplete: 'off'} + when 'store-only' then {autocomplete: 'off', data: {store: 'on'}} + else {} + end + end end diff --git a/app/views/home/profile.html.haml b/app/views/home/profile.html.haml index 0b164d73..31fa9ee9 100644 --- a/app/views/home/profile.html.haml +++ b/app/views/home/profile.html.haml @@ -6,7 +6,7 @@ = h(t('.user.title', user: show_user)) %small= t '.user.since', when: distance_of_time_in_words(Time.now, @current_user.created_on) = simple_form_for(@current_user, :url => update_profile_path) do |f| - = render :partial => 'shared/user_form_fields', :locals => {:f => f, :password_autocomplete => false} + = render :partial => 'shared/user_form_fields', :locals => {:f => f, :password_autocomplete => 'store-only'} .form-actions = submit_tag t('ui.save'), class: 'btn' .span5 diff --git a/app/views/shared/_user_form_fields.html.haml b/app/views/shared/_user_form_fields.html.haml index bf0af9bc..a0afffd6 100644 --- a/app/views/shared/_user_form_fields.html.haml +++ b/app/views/shared/_user_form_fields.html.haml @@ -3,12 +3,13 @@ = f.input :email -# need :required because :use_nil option on user model validators break the required mark = f.input :nick, required: true if FoodsoftConfig[:use_nick] --# you can disable password autocompletion by passing `password_autocomplete: false` to this partial +-# You can control password autocompletion by passing `password_autocomplete` to this partial. +-# Possible values: undefined/nil, true, false, 'store-only' -# see also https://github.com/foodcoops/foodsoft/wiki/Form-autocompletion - password_autocomplete = nil unless defined?(:password_autocomplete) -- passwd_opts = (password_autocomplete.nil? ? {} : {autocomplete: password_autocomplete ? 'on' : 'off', data: {store: 'on'}}) -= f.input :password, :required => f.object.new_record?, input_html: passwd_opts -= f.input :password_confirmation, :required => f.object.new_record?, input_html: passwd_opts +- password_html = autocomplete_flag_to_password_html(password_autocomplete) += f.input :password, :required => f.object.new_record?, input_html: password_html += f.input :password_confirmation, :required => f.object.new_record?, input_html: password_html = f.input :phone = f.simple_fields_for :settings_attributes do |s| From 3bf1392251ab71398b16c3eca8e35f11a7e23245 Mon Sep 17 00:00:00 2001 From: Julius Date: Sun, 22 Dec 2013 23:34:54 +0100 Subject: [PATCH 11/16] Show clearer error message on WikiCloth exception --- config/locales/de.yml | 2 +- config/locales/en.yml | 2 +- lib/foodsoft_wiki/app/helpers/pages_helper.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/locales/de.yml b/config/locales/de.yml index 9510b7d3..a0e6ed93 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1167,7 +1167,7 @@ de: title_list: Seiten-Liste body: title_toc: Inhalt - wikicloth_exception: Entschuldigung, ein Fehler ist aufgetreten. Möglicherweise ist ein ungewöhnlicher Text die Ursache. Bearbeiten der Seite kann helfen, diesen Fehler zu beseitigen. + wikicloth_exception: "Entschuldigung, ein Fehler ist beim Anzeigen der Wikiseite aufgetreten: »%{msg}«. Bearbeiten der Seite kann helfen, diesen Fehler zu beseitigen." create: notice: Seite wurde angelegt cshow: diff --git a/config/locales/en.yml b/config/locales/en.yml index 210ad10c..30f8720a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1171,7 +1171,7 @@ en: title_list: List of pages body: title_toc: Content - wikicloth_exception: An error occured. Sorry for that. It might be that the wiki syntax has been used in an unusual way. Please try to edit the page to get rid of this error. + wikicloth_exception: "I'm sorry to report that an error occured when interpreting the wiki page: %{msg}. Please try to fix it, and save the page again." create: notice: Page was created cshow: diff --git a/lib/foodsoft_wiki/app/helpers/pages_helper.rb b/lib/foodsoft_wiki/app/helpers/pages_helper.rb index bd6e6078..cfc8ea7b 100644 --- a/lib/foodsoft_wiki/app/helpers/pages_helper.rb +++ b/lib/foodsoft_wiki/app/helpers/pages_helper.rb @@ -4,8 +4,8 @@ module PagesHelper def wikified_body(body, title = nil) render_opts = {:locale => I18n.locale} # workaround for wikicloth 0.8.0 https://github.com/nricciar/wikicloth/pull/59 WikiCloth.new({:data => body+"\n", :link_handler => Wikilink.new, :params => {:referer => title}}).to_html(render_opts).html_safe - rescue - "#{t '.wikicloth_exception'}".html_safe # try the following with line breaks: === one === == two == = three = + rescue => e + "#{t('.wikicloth_exception', :msg => e)}".html_safe # try the following with line breaks: === one === == two == = three = end def link_to_wikipage(page, text = nil) From 45ad8e65247d7c711cabbae7678a01fbed0b4f1e Mon Sep 17 00:00:00 2001 From: wvengen Date: Mon, 23 Dec 2013 11:48:06 +0100 Subject: [PATCH 12/16] move helper to new module --- app/helpers/application_helper.rb | 10 ---------- app/helpers/shared_helper.rb | 13 +++++++++++++ 2 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 app/helpers/shared_helper.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fab0bde0..52ec9256 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -204,14 +204,4 @@ module ApplicationHelper end end - # provide input_html for password autocompletion - def autocomplete_flag_to_password_html(password_autocomplete) - case password_autocomplete - when true then {autocomplete: 'on'} - when false then {autocomplete: 'off'} - when 'store-only' then {autocomplete: 'off', data: {store: 'on'}} - else {} - end - end - end diff --git a/app/helpers/shared_helper.rb b/app/helpers/shared_helper.rb new file mode 100644 index 00000000..befd61c4 --- /dev/null +++ b/app/helpers/shared_helper.rb @@ -0,0 +1,13 @@ +module SharedHelper + + # provide input_html for password autocompletion + def autocomplete_flag_to_password_html(password_autocomplete) + case password_autocomplete + when true then {autocomplete: 'on'} + when false then {autocomplete: 'off'} + when 'store-only' then {autocomplete: 'off', data: {store: 'on'}} + else {} + end + end + +end From 5d8f71f834bb8752be2046028cca43316512c92f Mon Sep 17 00:00:00 2001 From: wvengen Date: Mon, 23 Dec 2013 11:50:57 +0100 Subject: [PATCH 13/16] move javascript a little --- app/assets/javascripts/application.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index d6f74838..26a18e14 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -35,15 +35,6 @@ $.fn.extend({ // Load following statements, when DOM is ready $(function() { - // The autocomplete attribute is used for both autocompletion and storing - // for passwords, it's nice to store it when editing one's own profile, - // but never autocomplete. - // This is only implemented for passwords. - $('input[type="password"][autocomplete="off"][data-store="on"]').each(function() { - $(this).on('change', function() { - $(this).removeAttr('autocomplete'); - }); - }); // Show/Hide a specific DOM element $(document).on('click', 'a[data-toggle-this]', function() { @@ -130,6 +121,15 @@ $(function() { $(this).children('input[type="submit"]').attr('disabled', 'disabled'); }); + // The autocomplete attribute is used for both autocompletion and storing + // for passwords, it's nice to store it when editing one's own profile, + // but never autocomplete. Only implemented for passwords. + $('input[type="password"][autocomplete="off"][data-store="on"]').each(function() { + $(this).on('change', function() { + $(this).removeAttr('autocomplete'); + }); + }); + // Use bootstrap datepicker for dateinput $('.datepicker').datepicker({format: 'yyyy-mm-dd', language: I18n.locale}); From f3c3b7af34ef32a0f168b6c59cc7561e264dc6fb Mon Sep 17 00:00:00 2001 From: Julius Date: Sat, 28 Dec 2013 20:07:28 +0100 Subject: [PATCH 14/16] Fix StockArticle#derive title i18n --- config/locales/de.yml | 2 ++ config/locales/en.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/config/locales/de.yml b/config/locales/de.yml index a0e6ed93..7cde8137 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1361,6 +1361,8 @@ de: title: Lagerartikel kopieren create: notice: Neuer Lagerartikel »%{name}« gespeichert. + derive: + title: Lagerartikel aus Vorlage erstellen destroy: notice: Artikel %{name} gelöscht. edit: diff --git a/config/locales/en.yml b/config/locales/en.yml index 30f8720a..aaa6e6de 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1365,6 +1365,8 @@ en: title: Copy stock article create: notice: New stock article "%{name}" was created. + derive: + title: Add stock article using template destroy: notice: Article %{name} was deleted. edit: From b22677ecedb64ce96fd305f109dc7d4167709234 Mon Sep 17 00:00:00 2001 From: Julius Date: Mon, 30 Dec 2013 11:26:10 +0100 Subject: [PATCH 15/16] Change order link from invoice form to avoid access problems --- app/views/finance/invoices/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/finance/invoices/_form.html.haml b/app/views/finance/invoices/_form.html.haml index 8f8ce228..d2c6d144 100644 --- a/app/views/finance/invoices/_form.html.haml +++ b/app/views/finance/invoices/_form.html.haml @@ -5,7 +5,7 @@ - if @invoice.delivery %p= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_delivery'), [@invoice.supplier,@invoice.delivery])).html_safe - if @invoice.order - %p= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_order'), @invoice.order)).html_safe + %p= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_order'), new_finance_order_path(order_id: @invoice.order.id))).html_safe = f.association :supplier, hint: false = f.input :number From 333606521828628092066134449d26a83faf9452 Mon Sep 17 00:00:00 2001 From: Julius Date: Mon, 30 Dec 2013 12:38:26 +0100 Subject: [PATCH 16/16] Add missing translations for ArticlePrice attributes --- config/locales/de.yml | 5 +++++ config/locales/en.yml | 5 +++++ config/locales/fr.yml | 5 +++++ config/locales/nl.yml | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/config/locales/de.yml b/config/locales/de.yml index 7cde8137..112e6f7a 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -27,6 +27,11 @@ de: article_category: description: Beschreibung name: Name + article_price: + deposit: Pfand + price: Nettopreis + tax: MwSt + unit_quantity: Gebindegröße delivery: delivered_on: Lieferdatum note: Notiz diff --git a/config/locales/en.yml b/config/locales/en.yml index aaa6e6de..5bf14ed1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -27,6 +27,11 @@ en: article_category: description: Description name: Name + article_price: + deposit: Deposit + price: Price (net) + tax: VAT + unit_quantity: Unit quantity delivery: delivered_on: Delivery date note: Note diff --git a/config/locales/fr.yml b/config/locales/fr.yml index eb40b75b..e73a720b 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -27,6 +27,11 @@ fr: article_category: description: Description name: Nom + article_price: + deposit: Consigne + price: Prix net + tax: TVA + unit_quantity: Unités par lot delivery: delivered_on: Date de réapprovisionnement note: diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 65c63213..e11dfebc 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -27,6 +27,11 @@ nl: article_category: description: Omschrijving name: Naam + article_price: + deposit: Statiegeld + price: Netto prijs + tax: BTW + unit_quantity: Groothandelseenheid delivery: delivered_on: Leverdatum note: Notitie