Skip to content

Commit f2206ea

Browse files
'#TDP - IW Realise CRUD
For guard and owner
1 parent ac2a119 commit f2206ea

File tree

22 files changed

+2214
-1170
lines changed

22 files changed

+2214
-1170
lines changed

IndividualWork/DIAGRAM/Diagram.mdj

Lines changed: 1358 additions & 773 deletions
Large diffs are not rendered by default.

IndividualWork/DIAGRAM/Main.png

37.3 KB
Loading

IndividualWork/Unit_tests/test_lab_work.rb

Lines changed: 0 additions & 36 deletions
This file was deleted.

IndividualWork/controller/controller.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,16 @@ def initialize(owners_list,guard_list,auto_list,log_mode = :all)
2121
@auto_list = auto_list
2222
end
2323

24-
def change_entity()
25-
@entity_list = (self.view.current_table.to_s.include? "Table_guards")? @guard_list : @owners_list
26-
self.data_list = @entity_list.get_k_n_elements_list(1,30,data_list:nil)
24+
def change_entity(num_tab)
25+
case num_tab
26+
when 0
27+
@entity_list = @owners_list
28+
when 1
29+
@entity_list = @guard_list
30+
else
31+
@entity_list = @owners_list
32+
end
33+
self.data_list = nil
2734
end
2835

2936
def refresh_data(k,n)
@@ -32,7 +39,7 @@ def refresh_data(k,n)
3239
else
3340
@entity_list.get_k_n_elements_list(k,n,data_list:self.data_list)
3441
end
35-
self.data_list.observer = self.view if self.data_list.view == nil
42+
self.data_list.observer = self.view if self.data_list.observer == nil
3643
self.data_list.notify(n)
3744
self.view.show(PLACEMENT_SCREEN)
3845
end
@@ -60,6 +67,7 @@ def delete_entities()
6067
self.logger.info("Deleting entity with ID {#{list_entites}")
6168
list_entites.each do |id_entity|
6269
@entity_list.delete_element_by_id(id_entity)
70+
#self.view.count_records -=1
6371
end
6472
refresh_data(self.view.num_page,self.view.count_records)
6573
rescue => e

IndividualWork/controller/controller_insert.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,20 @@ def create_entity(element)
99
self.logger.debug("Creating element with params #{element}")
1010
self.logger.info("Creating element with params #{element}")
1111
@controller.entity_list.push_element(element)
12+
calculate_count_records()
1213
@controller.refresh_data(self.view.num_page,self.view.count_records)
1314
rescue => e
14-
self.logger.error("Error while creating student: #{e}")
15+
self.logger.error("Error while creating element: #{e}")
16+
end
17+
18+
private
19+
def calculate_count_records()
20+
max_count = @controller.get_count_entities()
21+
if (self.view.count_records + 1 < self.view.count_records_default)
22+
self.view.count_records += 1 if self.view.count_records + 1 <= max_count
23+
else
24+
self.view.calculate_max_page(max_count)
25+
end
1526
end
1627

1728
end

IndividualWork/log.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ I, [2023-05-11T22:33:02.214789 #17799] INFO -- : Deleting entity with ID {[10]
1919
I, [2023-05-13T12:45:41.856087 #2410] INFO -- : Deleting entity with ID {[151]
2020
I, [2023-05-13T12:45:48.834753 #2410] INFO -- : Deleting entity with ID {[101, 150]
2121
I, [2023-05-14T17:32:02.809508 #4063] INFO -- : Deleting entity with ID {[152]
22+
I, [2023-05-16T10:12:29.460516 #6209] INFO -- : Deleting entity with ID {[10]
23+
I, [2023-05-16T10:13:00.155991 #6209] INFO -- : Deleting entity with ID {[14]
24+
I, [2023-05-16T10:16:23.515639 #6351] INFO -- : Deleting entity with ID {[15]
25+
I, [2023-05-16T10:17:39.963983 #6379] INFO -- : Deleting entity with ID {[16, 16, 17]
26+
I, [2023-05-16T10:22:05.966642 #6634] INFO -- : Deleting entity with ID {[18]
27+
I, [2023-05-16T12:09:58.474598 #13289] INFO -- : Deleting entity with ID {[4]

IndividualWork/logger/log_create.txt

Lines changed: 85 additions & 0 deletions
Large diffs are not rendered by default.

IndividualWork/logger/log_update.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ I, [2023-05-14T17:35:57.746734 #4219] INFO -- : Updating element with ID 6 and
3535
I, [2023-05-14T17:43:51.811646 #4722] INFO -- : Updating element with ID 6 and params {"number"=>3, "name"=>"Buisness", "topics"=>"Topic-Topic-45", "tasks"=>"Tasd task 3", "date_of_issue"=>"20.04.2022", "id"=>6}
3636
I, [2023-05-14T17:51:45.402904 #5136] INFO -- : Updating element with ID 5 and params {"number"=>2, "name"=>"Managment", "topics"=>"Topics", "tasks"=>"Tasd task 3", "date_of_issue"=>"17.04.2022", "id"=>5}
3737
I, [2023-05-14T17:54:25.504969 #5242] INFO -- : Updating element with ID 5 and params {"number"=>2, "name"=>"Managment", "topics"=>"Topics", "tasks"=>"Tasd task 3", "date_of_issue"=>"17.04.2022", "id"=>5}
38+
I, [2023-05-16T10:07:55.513020 #5853] INFO -- : Updating element with ID 10 and params {"name"=>"Next", "surname"=>"Prev", "lastname"=>"Pup", "phone"=>"+78523654595", "mail"=>"swPis@mail.ru", "id"=>10}
39+
I, [2023-05-16T12:22:05.922161 #14154] INFO -- : Updating element with ID 5 and params {"name"=>"Kiss", "surname"=>"Pussi", "lastname"=>"Nassi", "phone"=>"+78569568525", "mail"=>"swao_s2@mail.ru", "exp_year"=>5, "id"=>5}

IndividualWork/main.rb

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111
load './controller/controller_update.rb'
1212

1313
load './views/view.rb'
14-
load './views/modal_window_owners/modal_window_create_student.rb'
15-
load './views/modal_window_owners/modal_window_change_student.rb'
14+
#------------------Owner---------------
15+
load './views/modal_window_owners/modal_window_create_owner.rb'
16+
load './views/modal_window_owners/modal_window_change_owner.rb'
1617
#--------------------------------------
17-
#-------------------Labs---------------
18-
load './views/modal_window_labs/modal_window_create_labs.rb'
19-
load './views/modal_window_labs/modal_window_change_labs.rb'
18+
#------------------Guard---------------
19+
load './views/modal_window_guards/modal_window_create_guard.rb'
20+
load './views/modal_window_guards/modal_window_change_guard.rb'
21+
#--------------------------------------
22+
#-------------------Auto---------------
23+
#load './views/modal_window_labs/modal_window_create_labs.rb'
24+
#load './views/modal_window_labs/modal_window_change_labs.rb'
2025
#--------------------------------------
2126

2227
class Factory
@@ -35,8 +40,8 @@ def self.actions(type_action,enitity,files:nil)
3540
end
3641
end
3742

38-
def self.build_main_controller(entity_1,entity_2,entity_3)
39-
Controller.new(entity_1,entity_2,entity_3,:hybrid)
43+
def self.build_main_controller(owner:nil,guard:nil,auto:nil)
44+
Controller.new(owner,guard,auto,:hybrid)
4045
end
4146

4247
def self.build_main_window(application,
@@ -64,14 +69,14 @@ def self.build_controllers(controller_type,main_controller)
6469

6570
def self.build_modals(application,window_type)
6671
case window_type
67-
when :add_student
68-
Modal_create_student.new(application)
69-
when :change_student
70-
Modal_change_student.new(application)
71-
when :add_lab
72-
Modal_create_lab.new(application)
73-
when :change_lab
74-
Modal_change_lab.new(application)
72+
when :add_owner
73+
Modal_create_owner.new(application)
74+
when :change_owner
75+
Modal_change_owner.new(application)
76+
when :add_guard
77+
Modal_create_guard.new(application)
78+
when :change_guard
79+
Modal_change_guard.new(application)
7580
else
7681
raise ArgumentError, "Invalid window type: #{window_type}"
7782
end
@@ -93,32 +98,31 @@ def self.connection_window_controller(controller,window)
9398
json_guard = Factory.actions(:json,:guard,files:Persons_list_json.new(person:Guard_list.new(:json)))
9499

95100

96-
controller = Factory.build_main_controller(mysql_owner,mysql_guard,mysql_auto)
101+
controller = Factory.build_main_controller(owner:mysql_owner,guard:mysql_guard,auto:mysql_auto)
97102
contoller_modal_create = Factory.build_controllers(:insert,controller)
98103
controller_modal_change = Factory.build_controllers(:update,controller)
99104
application = FXApp.new
100105

101-
#modalWindow_create = Factory.build_modals(application,:add_student)
102-
#modalWindow_create_lab = Factory.build_modals(application,:add_lab)
103-
#modalWindow_change = Factory.build_modals(application,:change_student)
104-
#modalWindow_change_lab = Factory.build_modals(application,:change_lab)
105-
#Factory.connection_window_controller(contoller_modal_create,modalWindow_create)
106-
#Factory.connection_window_controller(contoller_modal_create,modalWindow_create_lab)
107-
#Factory.connection_window_controller(controller_modal_change,modalWindow_change)
108-
#Factory.connection_window_controller(controller_modal_change,modalWindow_change_lab)
106+
modalWindow_create_owner = Factory.build_modals(application,:add_owner)
107+
modalWindow_create_guard = Factory.build_modals(application,:add_guard)
108+
modalWindow_change_owner = Factory.build_modals(application,:change_owner)
109+
modalWindow_change_guard = Factory.build_modals(application,:change_guard)
110+
Factory.connection_window_controller(contoller_modal_create,modalWindow_create_owner)
111+
Factory.connection_window_controller(contoller_modal_create,modalWindow_create_guard)
112+
Factory.connection_window_controller(controller_modal_change,modalWindow_change_owner)
113+
Factory.connection_window_controller(controller_modal_change,modalWindow_change_guard)
109114

110115
view = Factory.build_main_window(application,
111-
modal_create_ent1:nil,
112-
modal_change_ent1:nil,
113-
modal_create_ent2:nil,
114-
modal_change_ent2:nil)
116+
modal_create_ent1:modalWindow_create_owner,
117+
modal_change_ent1:modalWindow_change_owner,
118+
modal_create_ent2:modalWindow_create_guard,
119+
modal_change_ent2:modalWindow_change_guard)
115120

116121
Factory.connection_controller_window(controller,view)
117122
Factory.connection_controller_window(contoller_modal_create,view)
118123
Factory.connection_controller_window(controller_modal_change,view)
119124
Factory.connection_window_controller(controller,view)
120125

121-
#view.showData(1,30)
122-
view.show(PLACEMENT_SCREEN)
126+
view.showData(1,8)
123127
application.create
124128
application.run

IndividualWork/model_entity/entity_list/Parking_list.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def get_k_n_elements_list(k,n,data_list:nil)
4040
@strategy.get_k_n_elements_list(k,n,data_list:data_list)
4141
end
4242

43-
def push_element(student)
44-
@strategy.push_element(student)
43+
def push_element(element)
44+
@strategy.push_element(element)
4545
end
4646

4747
def replace_element_by_id(id,element)

0 commit comments

Comments
 (0)