mods/standard/sets/all/account.rb in wagn-1.12.9 vs mods/standard/sets/all/account.rb in wagn-1.12.10

- old
+ new

@@ -8,11 +8,11 @@ Account[ id ] end def accountable? Card.toggle( rule(:accountable) ) and - fetch( :trait=>:account, :new=>{} ).ok?( :create) + fetch( :trait=>:account, :new=>{} ).permitted?( :create) #don't use #ok? here because we don't want to check part permissions end def parties @parties ||= (all_roles << self.id).flatten.reject(&:blank?) end @@ -56,40 +56,38 @@ email_params = params[:email] || {} subject = email_params[:subject] || Card.setting('*invite+*subject') || '' message = email_params[:message] || Card.setting('*invite+*message') || '' success = Card.setting "#{ Card[:invite].name }+#{ Card[:thanks].name }" + args[:buttons] = %{ + #{ submit_tag 'Invite' } + #{ link_to 'Cancel', previous_location } + } %{ #{ hidden_field_tag :success, "REDIRECT: #{success}" if success } #{ fieldset :subject, text_field( :email, :subject, :value=>subject, :size=>60 ) } #{ fieldset :message, text_area( :email, :message, :value=>message, :rows=>10, :cols => 60 ), :help => "We'll create a password and attach it to the email." } - <fieldset> - <div class="button-area"> - #{ submit_tag 'Invite' } - #{ link_to 'Cancel', previous_location } - </div> - </fieldset> + #{ _optional_render :button_fieldset, args } } end view :account, :perms=> lambda { |r| r.card.update_account_ok? } do |args| - - locals = {:slot=>self, :card=>card, :account=>card.account } - wrap_frame :account, args do - card_form :update, '', 'notify-success'=>'account details updated' do |form| - %{ - #{ hidden_field_tag 'success[id]', '_self' } - #{ hidden_field_tag 'success[view]', 'account' } - #{ render_account_detail } - <fieldset><div class="button-area">#{ submit_tag 'Save Changes' }</div></fieldset> - } - end + frame_and_form :update, args, 'notify-success'=>'account details updated' do + %{ + #{ render_account_detail } + #{ _optional_render :button_fieldset, args } + } end end + + def default_account_args args + default_new_account_args args + args[:buttons] = submit_tag 'Save Changes' + end view :account_detail, :perms=>lambda { |r| r.card.update_account_ok? } do |args| account = args[:account] || card.account @@ -116,55 +114,70 @@ end view :new_account, :perms=> lambda { |r| r.card.accountable? && !r.card.account } do |args| - wrap_frame :new_account, args do - card_form :update do |form| - %{ - #{ hidden_field_tag 'success[id]', '_self' } - #{ hidden_field_tag 'success[view]', 'account' } - #{ fieldset :email, text_field( 'card[account_args]', :email ) } - #{ _render_invitation_field } - } - end + frame_and_form :update, args do + %{ + #{ _render_email_fieldset } + #{ _render_invitation_field } + } end end + def default_new_account_args args + args[:hidden] = { :success => { :id=>'_self', :view=>'account' } } + end - view :signin, :tags=>:unknown_ok, :perms=>:none do |args| - frame_args = args.merge :title=>'Sign In', :show_help=>true, :optional_menu=>:never - signin_core = wrap_frame :signin, frame_args do - form_tag wagn_path('account/signin') do - %{ - #{ fieldset :email, text_field_tag( 'login', params[:login], :id=>'login_field' ) } - #{ fieldset :password, password_field_tag( 'password' ) } - <fieldset> - <div class="button-area"> - #{ submit_tag 'Sign in' } - #{ link_to '...or sign up!', wagn_path('account/signup') if Card.new(:type_id=>Card::AccountRequestID).ok? :create } - </div> - </fieldset> - } - end - end + view :email_fieldset do |args| + fieldset :email, text_field( 'card[account_args]', :email ), :editor=>'content' + end + + + view :signin_and_forgot_password, :perms=>:none do |args| %{ - <div id="sign-in">#{signin_core}</div> - <div id="forgot-password">#{_render_forgot_password}</div> + <div id="sign-in">#{ _render_signin args }</div> + <div id="forgot-password">#{ _render_forgot_password args }</div> } end + view :signin, :perms=>:none do |args| + args.merge!( { + :title=>'Sign In', + :optional_help=>:show, + :optional_menu=>:never, + :hidden=>{ :success=>'REDIRECT:*previous' }, + :buttons=> submit_tag( 'Sign in' ) + }) + if Card.new(:type_id=>Card::AccountRequestID).ok? :create + args[:buttons] += link_to( '...or sign up!', wagn_path("new/:account_request")) + end + + frame_and_form 'account/signin', args, :recaptcha=>:off do + [ + fieldset( :email, text_field_tag( 'login', params[:login], :id=>'login_field' ) ), + fieldset( :password, password_field_tag( 'password' ) ), + _optional_render( :button_fieldset, args ) + ] + end + end view :forgot_password, :perms=>:none do |args| - frame_args = args.merge :title=>'Forgot Password', :show_help=>true, :optional_menu=>:never - wrap_frame :forgot_password, frame_args do - form_tag wagn_path('account/forgot_password') do - %{ - #{ fieldset :email, text_field_tag( 'email', params[:email] ) } - <fieldset><div class="button-area">#{ submit_tag 'Reset my password' }</div></fieldset> - } - end + args.merge!( { + :title=>'Forgot Password', + :optional_help=>:show, + :optional_menu=>:never, + :hidden => { :success => { :view=>:forgot_password }}, + :buttons => submit_tag( 'Reset my password' ) + } ) + + frame_and_form 'account/forgot_password', args, :recaptcha=>:off, + 'notify-success'=>"Check your email for your new temporary password" do + [ + fieldset( :email, text_field_tag( 'email', params[:email] ) ), + _optional_render( :button_fieldset, args ) + ] end end end