sibprogrammer/owp

View on GitHub
app/views/sessions/reset_password.html.erb

Summary

Maintainability
Test Coverage
<% @page_title = t('reset_password.page_title') %>

<% javascript_tag do -%>
Ext.onReady(function() {

  var resetPasswordAction = function() {
    resetPasswordForm.getForm().submit({
      waitMsg: '<%= tjs('form.loading') %>',
      success: function(form, action) {
        Ext.MessageBox.show({
          msg: action.result.message,
          buttons: Ext.MessageBox.OK,
          icon: Ext.MessageBox.INFO,
          fn: function() {
            document.location.href = '<%= login_path %>';
          }
        });
      },
      failure: function(form, action) {
        Owp.form.errorHandler(form, action);
      }
    });
  }

  var resetPasswordForm = new Owp.form.BasicForm({
    labelWidth: 100,
    waitMsgTarget: !Ext.isGecko,
    url: '<%= reset_password_path %>?user_id=<%= @user.id %>&hash=<%= @hash %>',
    bodyStyle: 'padding: 15px 15px 0',
    keys: [{
      key: Ext.EventObject.ENTER,
      fn: resetPasswordAction
    }],
    labelWidth: 150,
    defaults: { width: 160 },
    items: [{
      fieldLabel: '<%= tjs('reset_password.new_password') %>',
      name: 'password',
      inputType: 'password',
      allowBlank: false
    }, {
      fieldLabel: '<%= tjs('reset_password.confirm_password') %>',
      name: 'password_confirmation',
      inputType: 'password',
      allowBlank: false
    }]
  });

  var resetPasswordWindow = new Owp.form.BasicFormWindow({
    applyTo: 'reset-password-window',
    title: '<%= tjs('reset_password.window_title') %>',
    iconCls: 'icon-window-reset-password',
    width: 380,
    autoHeight: true,
    y: 150,
    closable: false,
    resizable: false,
    draggable: false,
    plain: true,
    items: resetPasswordForm,
    buttons: [{
      text: '<%= tjs('form.button.back') %>',
      iconCls: 'icon-button-back',
      handler: function() {
        document.location.href = '<%= login_path %>';
      }
    }, {
      text: '<%= tjs('form.button.save') %>',
      iconCls: 'icon-button-save',
      handler: resetPasswordAction
    }]
  });

  resetPasswordWindow.show();

});
<% end -%>

<div id='reset-password-window'></div>