login.rb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class FormSchema::Form::Mobile::Login < FormSchema::Form
  3. # demo code for field loading, WIP
  4. # def object_attribute_fields
  5. # result = []
  6. # # ::ObjectManager::Object.new('User').attributes(context.current_user, nil, data_only: false).map(&:attribute).each do |attribute|
  7. # ::ObjectManager::Object.new('User').attributes(User.find(1), nil, data_only: false).map(&:attribute).each do |attribute|
  8. # field = ::FormSchema::FieldResolver.field_for_object_attribute(context: context, attribute: attribute)
  9. # result << field.schema if field
  10. # end
  11. # result
  12. # end
  13. def schema
  14. [
  15. FormSchema::Field::Text.new(
  16. context: context,
  17. name: 'login',
  18. label: __('Username / Email'),
  19. placeholder: __('Username / Email'),
  20. required: true,
  21. ).schema,
  22. FormSchema::Field::Password.new(
  23. context: context,
  24. name: 'password',
  25. label: __('Password'),
  26. placeholder: __('Password'),
  27. required: true,
  28. ).schema,
  29. # *object_attribute_fields,
  30. {
  31. isLayout: true,
  32. element: 'div',
  33. attrs: {
  34. class: 'mt-2.5 flex grow items-center justify-between text-white',
  35. },
  36. children: [
  37. FormSchema::Field::Checkbox.new(
  38. context: context,
  39. label: __('Remember me'),
  40. name: 'remember_me',
  41. ).schema,
  42. {
  43. isLayout: true,
  44. component: 'CommonLink',
  45. props: {
  46. class: 'text-right !text-white',
  47. link: 'TODO',
  48. },
  49. children: __('Forgot password?'),
  50. },
  51. ],
  52. },
  53. ]
  54. end
  55. end