rubbish_code 0.1.4 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 704e3897e8f44aebbccd201679e9ecf8188969a0fa0e2e9df5e025dce7bf8cd5
4
- data.tar.gz: 6fd1c258b63ba5079253bb0849f8ad66d689008691ac2a0b9da690abb51c95b5
3
+ metadata.gz: f803ff1bc99784c9ba272d7b7d392d37306ed4105495b9b615744eec533c6f1e
4
+ data.tar.gz: 744341824cbf7b0d0ec029697e2613f5a0388c330afec879170a90167fefccf7
5
5
  SHA512:
6
- metadata.gz: 7c4dbf4065b011aaf46803956e843295f675e6851c2f834417effaf0dd244a6b4cf3045cecb6d27d0bbbd2d632710d676f186c2fe3227ac359e581dfb8c8ba24
7
- data.tar.gz: 953b81ec8a65ff9d03fab491b798975a1749a10fbc3b988ab13e893b1d4c7d8d0cfac1ce6bc4405762de19b767d49eea544764afb629367049ec2bddc390e13a
6
+ metadata.gz: 652f89913823bcf31ab9ae1eac5720d2f766f982385f059ce43693c9c4b13ac5831d9abc6b58e5e0318898f2f65035dab7efec104decd9dfb47c972e4ea6f5be
7
+ data.tar.gz: 979143719ca13ac31daa84dcefa2419950c7e3254904c300ae38b50e34c8ac89b1dee20549e7847927da754ab2be56464377a28a4245712b72f34ddbda3398a0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubbishCode
4
- VERSION = "0.1.4"
4
+ VERSION = "1.1.0"
5
5
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require './LabStudents/util/logger_holder'
2
+ require 'source/util/logger_holder'
3
3
  require 'win32api'
4
4
 
5
5
  class StudentInputFormControllerCreate
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require './LabStudents/util/logger_holder'
3
+ require 'source/util/logger_holder'
4
4
  require 'win32api'
5
5
 
6
6
  class StudentInputFormControllerEdit
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require './LabStudents/views/main_window'
4
- require './LabStudents/repositories/student_repository'
5
- require './LabStudents/repositories/adapters/db_source_adapter'
6
- require './LabStudents/repositories/containers/data_list_student_short'
7
- require './LabStudents/views/student_input_form'
8
- require './LabStudents/controllers/student_input_form/student_input_form_controller_create'
9
- require './LabStudents/controllers/student_input_form/student_input_form_controller_edit'
10
- require './LabStudents/util/logger_holder'
3
+ require 'source/views/main_window'
4
+ require 'source/repositories/student_repository'
5
+ require 'source/repositories/adapters/db_source_adapter'
6
+ require 'source/repositories/containers/data_list_student_short'
7
+ require 'source/views/student_input_form'
8
+ require 'source/controllers/student_input_form/student_input_form_controller_create'
9
+ require 'source/controllers/student_input_form/student_input_form_controller_edit'
10
+ require 'source/util/logger_holder'
11
11
  require 'win32api'
12
12
 
13
13
  class TabStudentsController
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require './LabStudents/repositories/data_sources/db_data_source'
4
- require './LabStudents/models/student'
5
- require './LabStudents/models/student_short'
6
- require './LabStudents/repositories/containers/data_list_student_short'
3
+ require 'source/repositories/data_sources/db_data_source'
4
+ require 'source/models/student'
5
+ require 'source/models/student_short'
6
+ require 'source/repositories/containers/data_list_student_short'
7
7
 
8
8
  class DBSourceAdapter
9
9
  def initialize
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require './LabStudents/repositories/containers/data_table'
3
+ require 'source/repositories/containers/data_table'
4
4
 
5
5
  class DataList
6
6
  # Это "абстрактный" класс
@@ -7,7 +7,8 @@ class DBDataSource
7
7
  @instance_mutex = Mutex.new
8
8
 
9
9
  def initialize
10
- db_config = YAML.load_file('./LabStudents/db_config/config.yaml').transform_keys(&:to_sym)
10
+ #тут изменить путь к своему конфигу
11
+ db_config = YAML.load_file('C:/Users/jakep/GitHub/Ruby_Moment/LabStudents/db_config/config.yaml').transform_keys(&:to_sym)
11
12
  @client = Mysql2::Client.new(db_config)
12
13
  @client.query_options.merge!(symbolize_keys: true)
13
14
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require './LabStudents/models/student'
4
- require './LabStudents/models/student_short'
5
- require './LabStudents/repositories/containers/data_list_student_short'
3
+ require 'source/models/student'
4
+ require 'source/models/student_short'
5
+ require 'source/repositories/containers/data_list_student_short'
6
6
 
7
7
  class FileDataSource
8
8
  attr_writer :data_transformer
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+ require_relative 'tab_students'
5
+
6
+ class MainWindow
7
+ include Glimmer
8
+
9
+ def initialize
10
+ @view_tab_students = TabStudents.new
11
+ end
12
+
13
+ def create
14
+ window('Универ', 900, 200) {
15
+ tab {
16
+ tab_item('Студенты') {
17
+ @view_tab_students.create
18
+ }
19
+
20
+ tab_item('Вкладка 2') { }
21
+ tab_item('Вкладка 3') { }
22
+ }
23
+ }
24
+ end
25
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+ require 'source/controllers/student_input_form/student_input_form_controller_create'
5
+ require 'source/models/student_base'
6
+ require 'source/controllers/tab_students_controller'
7
+ require 'win32api'
8
+
9
+ class StudentInputForm
10
+ include Glimmer
11
+
12
+ def initialize(controller, existing_student = nil)
13
+ @existing_student = existing_student.to_hash unless existing_student.nil?
14
+ @controller = controller
15
+ @entries = {}
16
+ end
17
+
18
+ def on_create
19
+ @controller.on_view_created
20
+ end
21
+
22
+ def create
23
+ @root_container = window('Универ', 300, 150) {
24
+ resizable false
25
+
26
+ vertical_box {
27
+ @student_form = form {
28
+ stretchy false
29
+
30
+ fields = [[:last_name, 'Фамилия', false], [:first_name, 'Имя', false], [:father_name, 'Отчество', false], [:git, 'Гит', true], [:telegram, 'Телеграм', true], [:email, 'Почта', true], [:phone, 'Телефон', true]]
31
+
32
+ fields.each do |field|
33
+ @entries[field[0]] = entry {
34
+ label field[1]
35
+ }
36
+ end
37
+ }
38
+
39
+ button('Сохранить') {
40
+ stretchy false
41
+
42
+ on_clicked {
43
+ values = @entries.transform_values { |v| v.text.force_encoding("utf-8").strip }
44
+ values.transform_values! { |v| v.empty? ? nil : v}
45
+
46
+ @controller.process_fields(values)
47
+ @controller.refresh()
48
+ }
49
+ }
50
+ }
51
+ }
52
+ on_create
53
+ @root_container
54
+ end
55
+
56
+ def set_value(field, value)
57
+ return unless @entries.include?(field)
58
+
59
+ @entries[field].text = value
60
+ end
61
+
62
+ def make_readonly(*fields)
63
+ fields.each do |field|
64
+ @entries[field].read_only = true
65
+ end
66
+ end
67
+
68
+ def close
69
+ @root_container.destroy
70
+ end
71
+ end
@@ -0,0 +1,171 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+ require 'source/controllers/tab_students_controller'
5
+ require 'source/views/student_input_form'
6
+
7
+ class TabStudents
8
+ include Glimmer
9
+
10
+ STUDENTS_PER_PAGE = 20
11
+
12
+ def initialize
13
+ @controller = TabStudentsController.new(self)
14
+ @current_page = 1
15
+ @total_count = 0
16
+ end
17
+
18
+ def on_create
19
+ @controller.on_view_created
20
+ @controller.refresh_data(@current_page, STUDENTS_PER_PAGE)
21
+ end
22
+
23
+ # Метод наблюдателя datalist
24
+ def on_datalist_changed(new_table)
25
+ arr = new_table.to_2d_array
26
+ arr.map do |row|
27
+ row[3] = [row[3][:value], contact_color(row[3][:type])] unless row[3].nil?
28
+ end
29
+ @table.model_array = arr
30
+ end
31
+
32
+ def update_student_count(new_cnt)
33
+ @total_count = new_cnt
34
+ @page_label.text = "#{@current_page} / #{(@total_count / STUDENTS_PER_PAGE.to_f).ceil}"
35
+ end
36
+
37
+ def contact_color(type)
38
+ case type
39
+ when 'telegram'
40
+ '#00ADB5'
41
+ when 'email'
42
+ '#F08A5D'
43
+ when 'phone'
44
+ '#B83B5E'
45
+ else
46
+ '#000000'
47
+ end
48
+ end
49
+
50
+ def create
51
+ root_container = horizontal_box {
52
+ # Секция 1
53
+ vertical_box {
54
+ stretchy false
55
+
56
+ form {
57
+ stretchy false
58
+
59
+ @filter_last_name_initials = entry {
60
+ label 'Фамилия И. О.'
61
+ }
62
+
63
+ @filters = {}
64
+ fields = [[:git, 'Гит'], [:email, 'Почта'], [:phone, 'Телефон'], [:telegram, 'Телеграм']]
65
+
66
+ fields.each do |field|
67
+ @filters[field[0]] = {}
68
+
69
+ @filters[field[0]][:combobox] = combobox {
70
+ label "#{field[1]} имеется?"
71
+ items ['Не важно', 'Есть', 'Нет']
72
+ selected 0
73
+
74
+ on_selected do
75
+ if @filters[field[0]][:combobox].selected == 1
76
+ @filters[field[0]][:entry].read_only = false
77
+ else
78
+ @filters[field[0]][:entry].text = ''
79
+ @filters[field[0]][:entry].read_only = true
80
+ end
81
+ end
82
+ }
83
+
84
+ @filters[field[0]][:entry] = entry {
85
+ label field[1]
86
+ read_only true
87
+ }
88
+ end
89
+ }
90
+ }
91
+
92
+ # Секция 2
93
+ vertical_box {
94
+ @table = refined_table(
95
+ table_editable: false,
96
+ filter: lambda do |row_hash, query|
97
+ utf8_query = query.force_encoding("utf-8")
98
+ row_hash['Фамилия И. О'].include?(utf8_query)
99
+ end,
100
+ table_columns: {
101
+ '#' => :text,
102
+ 'Фамилия И. О' => :text,
103
+ 'Гит' => :text,
104
+ 'Контакт' => :text_color
105
+ },
106
+ per_page: STUDENTS_PER_PAGE
107
+ )
108
+
109
+ @pages = horizontal_box {
110
+ stretchy false
111
+
112
+ button("<") {
113
+ stretchy true
114
+
115
+ on_clicked do
116
+ @current_page = [@current_page - 1, 1].max
117
+ @controller.refresh_data(@current_page, STUDENTS_PER_PAGE)
118
+ end
119
+
120
+ }
121
+ @page_label = label("...") { stretchy false }
122
+ button(">") {
123
+ stretchy true
124
+
125
+ on_clicked do
126
+ @current_page = [@current_page + 1, (@total_count / STUDENTS_PER_PAGE.to_f).ceil].min
127
+ @controller.refresh_data(@current_page, STUDENTS_PER_PAGE)
128
+ end
129
+ }
130
+ }
131
+ }
132
+
133
+ # Секция 3
134
+ vertical_box {
135
+ stretchy false
136
+
137
+ button('Добавить') {
138
+ stretchy false
139
+
140
+ on_clicked {
141
+ @controller.show_modal_add
142
+ }
143
+ }
144
+ button('Изменить') {
145
+ stretchy false
146
+
147
+ on_clicked {
148
+ @controller.show_modal_edit(@current_page, STUDENTS_PER_PAGE, @table.selection) unless @table.selection.nil?
149
+ }
150
+ }
151
+ button('Удалить') {
152
+ stretchy false
153
+
154
+ on_clicked {
155
+ @controller.delete_selected(@current_page, STUDENTS_PER_PAGE, @table.selection) unless @table.selection.nil?
156
+ @controller.refresh_data(@current_page, STUDENTS_PER_PAGE)
157
+ }
158
+ }
159
+ button('Обновить') {
160
+ stretchy false
161
+
162
+ on_clicked {
163
+ @controller.refresh_data(@current_page, STUDENTS_PER_PAGE)
164
+ }
165
+ }
166
+ }
167
+ }
168
+ on_create
169
+ root_container
170
+ end
171
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubbish_code
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Epps
@@ -61,6 +61,9 @@ files:
61
61
  - lib/source/repositories/data_sources/transformers/data_transformer_yaml.rb
62
62
  - lib/source/repositories/student_repository.rb
63
63
  - lib/source/util/logger_holder.rb
64
+ - lib/source/views/main_window.rb
65
+ - lib/source/views/student_input_form.rb
66
+ - lib/source/views/tab_students.rb
64
67
  - rubbish_code.gemspec
65
68
  - sig/ribbish_code.rbs
66
69
  homepage: https://github.com/Jakepps/Ruby_Moment