Skip to content

Commit a021d91

Browse files
'#TDP - IW Change modal_window_auto
1 parent 2554d0a commit a021d91

File tree

6 files changed

+31
-77
lines changed

6 files changed

+31
-77
lines changed

IndividualWork/logger/log_create.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,5 @@ I, [2023-05-20T09:30:22.213572 #3100] INFO -- : Creating element with params {"
250250
I, [2023-05-20T09:45:36.481855 #4299] INFO -- : Creating element with params {"name"=>"Ownern", "surname"=>"Owners", "lastname"=>"Ownerl", "phone"=>"+79562563625", "mail"=>"exp@mail.ru", "id"=>nil}
251251
I, [2023-05-20T10:07:48.667519 #5369] INFO -- : Creating element with params {"name"=>"Max", "surname"=>"Petrenko", "lastname"=>"", "phone"=>"+78558565625", "mail"=>"max@gmail.com", "exp_year"=>14}
252252
I, [2023-05-20T10:18:46.562407 #5773] INFO -- : Creating element with params {"name"=>"Name", "surname"=>"Surname", "lastname"=>"Lastname", "phone"=>"+78565698565", "mail"=>nil, "exp_year"=>15}
253+
I, [2023-05-20T10:27:19.807457 #6397] INFO -- : Creating element with params {"id_owner"=>"2", "model"=>"X6", "color"=>"green", "surname_owner"=>"Потапов", "mark"=>"BMW"}
254+
I, [2023-05-20T10:47:04.579587 #7440] INFO -- : Creating element with params {"id_owner"=>"20", "model"=>"X6", "color"=>"pink", "surname_owner"=>"Lopi", "mark"=>"BMW"}

IndividualWork/logger/log_update.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ I, [2023-05-20T09:35:35.553136 #3865] INFO -- : Updating element with ID 5 and
4343
I, [2023-05-20T09:46:16.824917 #4299] INFO -- : Updating element with ID 25 and params {"name"=>"Ownern", "surname"=>"Surnameower", "lastname"=>"Ownerl", "phone"=>"+79562563625", "mail"=>"exp@mail.ru", "id"=>25}
4444
I, [2023-05-20T10:00:41.149502 #4934] INFO -- : Updating element with ID 2 and params {"name"=>"Денис", "surname"=>"Дроздов", "lastname"=>"Авдеевич", "phone"=>"+75259561235", "mail"=>"guar7@gmail.com", "exp_year"=>5, "id"=>2}
4545
I, [2023-05-20T10:18:11.811320 #5773] INFO -- : Updating element with ID 8 and params {"name"=>"Max", "surname"=>"Petrenko", "lastname"=>nil, "phone"=>"+78558565625", "mail"=>"max@gmail.com", "exp_year"=>10, "id"=>8}
46+
I, [2023-05-20T10:47:30.905834 #7440] INFO -- : Updating element with ID 9 and params {"id"=>9, "id_owner"=>20, "model"=>"Higlander", "color"=>"pink", "surname_owner"=>"Lopi", "mark"=>"Toyota"}

IndividualWork/model_person/person_DB/owners_list_DB.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def initialize()
1010
end
1111

1212
def get_element_by_id(id)
13-
owner = @dbcon.crud_by_db("Select * FROM Owner WHERE id = #{id}").to_a
14-
owner = clearData(owner[0])
13+
owner = @dbcon.crud_by_db("Select * FROM Owner WHERE id = #{id}").to_a[0]
14+
owner = clearData(owner) if owner != nil
1515
return owner
1616
end
1717

IndividualWork/views/modal_window.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ def removeTimeout(timerId,app)
4949
app.removeTimeout(timerId)
5050
end
5151

52+
def message_warning(text)
53+
FXMessageBox.warning(self,
54+
MBOX_OK,
55+
"Warning",
56+
text)
57+
end
58+
5259

5360
def check_letter(elem)
5461
elem.match?(/^[A-zА-яЁё\s]+$/)

IndividualWork/views/modal_window_auto/modal_window_change_auto.rb

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11

2-
require 'fox16'
32

4-
include Fox
3+
require_relative '../modal_Window.rb'
4+
5+
class Modal_change_auto < Modal_Window
56

6-
class Modal_change_auto < FXDialogBox
7-
attr_writer :controller
87
def initialize(app)
9-
@app = app
10-
11-
super(app, "Change auto", :width => 300, :height => 150)
8+
super(app, "Add auto", width:300, height:150)
129

1310
@model_filed = {"id"=>nil,"id_owner" =>nil,"model" => nil, "color" => nil,"surname_owner"=>nil,"mark"=>nil}
1411
matrix = FXMatrix.new(self, 2, MATRIX_BY_COLUMNS|LAYOUT_FILL_X)
@@ -23,19 +20,6 @@ def initialize(app)
2320

2421
end
2522

26-
def addTimeoutCheck(data:nil)
27-
if(self.shown?) then
28-
@timeout_id = @app.addTimeout(500, :repeat => true) do
29-
if @model_filed["id_owner"]!=nil && @model_filed["model"] != nil && @model_filed["color"] != nil then
30-
@ok_btn.enable
31-
else
32-
@ok_btn.disable
33-
end
34-
end
35-
end
36-
37-
end
38-
3923
def get_personal_data(id)
4024
@model_data = []
4125
@model_data = @controller.get_element_by_id(id)
@@ -53,16 +37,6 @@ def get_personal_data(id)
5337
end
5438

5539
private
56-
attr_reader :controller
57-
def create_close_button(horizontal_frame)
58-
close_button = FXButton.new(horizontal_frame, "Close", nil,nil, :opts => BUTTON_NORMAL|LAYOUT_RIGHT)
59-
close_button.connect(SEL_COMMAND) do |sender, selector, data|
60-
@app.removeTimeout(@timeout_id)
61-
clear_inputs()
62-
self.hide
63-
end
64-
close_button.layoutHints |= LAYOUT_TOP|LAYOUT_RIGHT|LAYOUT_FILL_X
65-
end
6640

6741
def create_button_ok(horizontal_frame)
6842
ok_button = FXButton.new(horizontal_frame, "Ok", nil,nil, :opts => BUTTON_NORMAL|LAYOUT_RIGHT)
@@ -72,8 +46,8 @@ def create_button_ok(horizontal_frame)
7246
model = @controller.get_model(@model.text)
7347
@model_filed["surname_owner"] = owner["surname"] if owner !=nil
7448
@model_filed["mark"] = model["mark"] if model!=nil
75-
print @model_filed,"\n"
76-
if owner!= nil && model != nil then
49+
50+
if owner!= nil && model != nil && owner != [] then
7751
answer = FXMessageBox.question(
7852
self,
7953
MBOX_YES_NO,
@@ -87,9 +61,8 @@ def create_button_ok(horizontal_frame)
8761
clear_inputs()
8862
self.hide
8963
end
90-
else
91-
FXMessageBox.warning(self,MBOX_OK,"Warning",
92-
"Owner/model don't exists, show directory!")
64+
else
65+
message_warning("Owner/model don't exists, show directory!")
9366
end
9467

9568

@@ -142,12 +115,10 @@ def validate_field(nameField,method_validate,name)
142115
end
143116
end
144117

145-
def message(text)
146-
FXMessageBox.warning(self,
147-
MBOX_OK,
148-
"Warning",
149-
text)
118+
def require_field_to_fill()
119+
@model_filed["id_owner"]!=nil && @model_filed["model"] != nil && @model_filed["color"] != nil
150120
end
121+
151122

152123
def clear_inputs()
153124
@name.setText('')

IndividualWork/views/modal_window_auto/modal_window_create_auto.rb

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11

2-
require 'fox16'
2+
require_relative '../modal_Window.rb'
33

4-
include Fox
5-
6-
class Modal_create_auto < FXDialogBox
7-
attr_writer :controller
4+
class Modal_create_auto < Modal_Window
85
def initialize(app)
9-
@app = app
106

11-
super(app, "Add auto", :width => 300, :height => 200)
7+
super(app, "Add auto", width:300, height:150)
128

139
@model_fileds = {"id_owner" =>nil,"model" => nil, "color" => nil,"surname_owner"=>nil,"mark"=>nil}
1410
matrix = FXMatrix.new(self, 2, MATRIX_BY_COLUMNS|LAYOUT_FILL_X)
@@ -22,31 +18,8 @@ def initialize(app)
2218

2319
end
2420

25-
def addTimeoutCheck(data:nil)
26-
if(self.shown?) then
27-
@timeout_id = @app.addTimeout(500, :repeat => true) do
28-
if @model_fileds["id_owner"]!=nil && @model_fileds["model"] != nil && @model_fileds["color"] != nil then
29-
@ok_btn.enable
30-
else
31-
@ok_btn.disable
32-
end
33-
end
34-
end
35-
36-
end
37-
3821
private
39-
attr_reader :controller
40-
def create_close_button(horizontal_frame)
41-
close_button = FXButton.new(horizontal_frame, "Close", nil,nil, :opts => BUTTON_NORMAL|LAYOUT_RIGHT)
42-
close_button.connect(SEL_COMMAND) do |sender, selector, data|
43-
@app.removeTimeout(@timeout_id)
44-
clear_inputs()
45-
self.hide
46-
end
47-
close_button.layoutHints |= LAYOUT_TOP|LAYOUT_RIGHT|LAYOUT_FILL_X
48-
end
49-
22+
5023
def create_button_ok(horizontal_frame)
5124
ok_button = FXButton.new(horizontal_frame, "Ok", nil,nil, :opts => BUTTON_NORMAL|LAYOUT_RIGHT)
5225
ok_button.disable
@@ -70,8 +43,7 @@ def create_button_ok(horizontal_frame)
7043
self.hide
7144
end
7245
else
73-
FXMessageBox.warning(self,MBOX_OK,"Warning",
74-
"Owner/model don't exists, show directory!")
46+
message_warning("Owner/model don't exists, show directory!")
7547
end
7648

7749

@@ -112,6 +84,9 @@ def clear_inputs()
11284
@model.setText('')
11385
end
11486

87+
def require_field_to_fill()
88+
@model_fileds["id_owner"]!=nil && @model_fileds["model"] != nil && @model_fileds["color"] != nil
89+
end
11590

11691
def check_letter(elem)
11792
elem.match?(/^[A-zА-яЁё\s\-0-9\#]+$/)
@@ -128,7 +103,5 @@ def validate_name(text)
128103
def validate_id(text)
129104
text.match?(/^[0-9]{1,999}$/)
130105
end
131-
132-
133106
end
134107

0 commit comments

Comments
 (0)