rubbish_code 1.0.0 → 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: 3ff6f894a469a5e30f9503c213a3a3bc722644f31c029a71be8fee6ccf374c0f
4
- data.tar.gz: f3974e72e1da817190175d4e6570cc1f31c079dacfd91d5cb7d8ad56cf9d6bc9
3
+ metadata.gz: f803ff1bc99784c9ba272d7b7d392d37306ed4105495b9b615744eec533c6f1e
4
+ data.tar.gz: 744341824cbf7b0d0ec029697e2613f5a0388c330afec879170a90167fefccf7
5
5
  SHA512:
6
- metadata.gz: 8521e9757f7ac4f1051bab3b1ceb90174d240df639586ec644621308781374433060551621de84df2222be89b87acb593a16c7bf0122c55f8005e7931860a1db
7
- data.tar.gz: 23778ca852b39757f12b23ccd8da11c0c7ffdba28884050c567b6c3593e3176c43d9f82194fd55a03f84dd3b32d091b1124ea0c687e9079c6a8d1d558d2d6453
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 = "1.0.0"
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: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Epps
@@ -61,7 +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
- - rubbish_code-0.1.4.gem
64
+ - lib/source/views/main_window.rb
65
+ - lib/source/views/student_input_form.rb
66
+ - lib/source/views/tab_students.rb
65
67
  - rubbish_code.gemspec
66
68
  - sig/ribbish_code.rbs
67
69
  homepage: https://github.com/Jakepps/Ruby_Moment
Binary file