Sha256: df0f355c54bd4719a1a83c3dabf0c91c1e4d653fa2fc2ccf4fbd0ec4d42a3932
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
# frozen_string_literal: true require 'glimmer-dsl-libui' require_relative '../Gem_fuss/lib/source/roller' require_relative '../Gem_fuss/lib/source/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_gem2-1.1.5 | lib/source/student_input_form.rb |