Sha256: 6a14182de4c27e1cc94f97162e824ec00501e8b1deb0389db26f49df345ca428
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
require_relative './../data_construct_pattern/data_construct_pattarn.rb' require_relative './create_student_controller.rb' require_relative './edit_student_controller.rb' class ViewController attr_private_accessor :model attr_private_accessor :data_list attr_accessor :selected_page attr_accessor :on_update_data attr_accessor :on_add_student_clicked def initialize(model, &on_update_data) self.model = model self.on_update_data = on_update_data self.selected_page = 0 self.data_list = DataListStudentShort.new(list: [], data_constructor: DefaultDataConstructPattern.new()) self.model.get_students(0, 10, self.data_list) end end # StudentsListViewDelegate class ViewController def pages_count (model.count / 10.0).ceil end def table_columns self.data_list.get_names end def next_page if self.selected_page != self.pages_count - 1 self.selected_page += 1 end puts self.selected_page update_table() end def last_page if self.selected_page != 0 self.selected_page -= 1 end puts self.selected_page update_table() end def update_table model.get_students(self.selected_page * 10, (self.selected_page + 1) * 10, self.data_list) self.on_update_data.call() end def open_student_creation_window() on_add_student_clicked.call() end def open_student_editing_window(id) student = model.get_student(id) controller = EditStudentController.new(student) controller.onCreate = lambda { |student| model.replace_student(controller.edit_user_id, student) update_table() } controller.ui.present end def remove_student(id) model.remove_student(id) update_table() end def add_student(student) model.add_student(student) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mc_delta-0.1.0 | lib/source/controllers/view_controller.rb |