Class: StudentCreateForm
- Inherits:
-
Object
- Object
- StudentCreateForm
- Includes:
- Glimmer
- Defined in:
- lib/source/student_create_form.rb
Instance Method Summary collapse
- #close ⇒ Object
- #create ⇒ Object
-
#initialize(controller, existing_student = nil) ⇒ StudentCreateForm
constructor
puts “hello”.
- #make_readonly(*fields) ⇒ Object
- #on_create ⇒ Object
- #set_value(field, value) ⇒ Object
Constructor Details
#initialize(controller, existing_student = nil) ⇒ StudentCreateForm
puts “hello”
12 13 14 15 16 |
# File 'lib/source/student_create_form.rb', line 12 def initialize(controller,existing_student = nil) @existing_student = existing_student.to_hash unless existing_student.nil? @controller = controller @entries = {} end |
Instance Method Details
#close ⇒ Object
64 65 66 |
# File 'lib/source/student_create_form.rb', line 64 def close @root_container.destroy end |
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/source/student_create_form.rb', line 22 def create @root_container = window('Универ', 300, 200) { vertical_box { @student_form = form { stretchy false fields = [[:last_name, 'Фамилия', false], [:first_name, 'Имя', false], [:paternal_name, 'Отчество', false], [:git, 'Гит', true], [:telegram, 'Телеграм', true], [:email, 'Почта', true], [:phone, 'Телефон', true]] fields.each do |field| @entries[field[0]] = entry { label field[1] } end } ('Сохранить') { stretchy false on_clicked { values = @entries.transform_values { |v| v.text.force_encoding("utf-8").strip } values.transform_values! { |v| v.empty? ? nil : v} @controller.process_fields(values) } } } } on_create @root_container end |
#make_readonly(*fields) ⇒ Object
59 60 61 62 63 |
# File 'lib/source/student_create_form.rb', line 59 def make_readonly(*fields) fields.each do |field| @entries[field].read_only = true end end |
#on_create ⇒ Object
18 19 20 |
# File 'lib/source/student_create_form.rb', line 18 def on_create @controller.on_view_created end |
#set_value(field, value) ⇒ Object
53 54 55 56 57 |
# File 'lib/source/student_create_form.rb', line 53 def set_value(field, value) return unless @entries.include?(field) @entries[field].text = value end |