Sha256: ad6b5d0803f4c775030b5266a2ab5ae8566bf1f77509c51aa75d3e5f0350be24
Contents?: true
Size: 1.92 KB
Versions: 1
Compression:
Stored size: 1.92 KB
Contents
# frozen_string_literal: true require 'glimmer-dsl-libui' require_relative '../mc_gem/lib/source/controllers/student_input_form_controller' require_relative '../mc_gem/lib/source/model/StudentBase' require 'win32api' class StudentInputForm include Glimmer def initialize(controller,existing_student = nil) @existing_student = existing_student.to_hash unless existing_student.nil? @controller = controller @entries = {} end def on_create @controller.on_view_created end def create @root_container = window('Универ', 300, 150) { resizable false vertical_box { @student_form = form { stretchy false fields = [[:last_name, 'Фамилия', false], [:first_name, 'Имя', false], [:parental_name, 'Отчество', false], [:git, 'Гит', true], [:telegram, 'Телеграм', true], [:email, 'Почта', true], [:phone, 'Телефон', true]] fields.each do |field| @entries[field[0]] = entry { label field[1] text @existing_student[field[0]] unless @existing_student.nil? read_only field[2] unless @existing_student.nil? } end } button('Сохранить') { 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) @controller.refresh } } } } on_create @root_container end def set_value(field, value) return unless @entries.include?(field) @entries[field].text = value end def make_readonly(*fields) fields.each do |field| @entries[field].read_only = true end end def close @root_container.destroy end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mc_gem-0.0.1 | Lab2/student_input_form.rb |