Sha256: 52db72ab1408caaeaf96e23e05aa77f82a2032b4002286fe89ebe6127889e2e7
Contents?: true
Size: 1.92 KB
Versions: 3
Compression:
Stored size: 1.92 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_accessor :data_list attr_accessor :selected_page attr_accessor :on_update_data attr_accessor :on_add_student_clicked attr_accessor :on_edit_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) on_edit_student_clicked.call(id) end def remove_student(id) model.remove_student(id) update_table() end def add_student(student) model.add_student(student) puts model.count end def get_student(id) model.get_student(id) end def replace_student(id, student) model.replace_student(id, student) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mc_delta-0.4.0 | lib/source/controllers/view_controller.rb |
mc_delta-0.3.0 | lib/source/controllers/view_controller.rb |
mc_delta-0.2.0 | lib/source/controllers/view_controller.rb |