jewerly_system 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +84 -0
  3. data/Gemfile +13 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +1 -0
  6. data/jewelry_system.gemspec +17 -0
  7. data/lib/jewerly_system/version.rb +5 -0
  8. data/lib/jewerly_system.rb +10 -0
  9. data/lib/source/customer/controllers/customer_input_form_controller_create.rb +44 -0
  10. data/lib/source/customer/controllers/customer_input_form_controller_edit.rb +52 -0
  11. data/lib/source/customer/controllers/customer_list_controller.rb +104 -0
  12. data/lib/source/customer/customer_db_data_source.rb +63 -0
  13. data/lib/source/customer/ui/customer_input_form.rb +70 -0
  14. data/lib/source/customer/ui/customer_list_view.rb +159 -0
  15. data/lib/source/master/controllers/master_controller.rb +57 -0
  16. data/lib/source/master/controllers/master_input_form_controller_create.rb +44 -0
  17. data/lib/source/master/controllers/master_input_form_controller_edit.rb +53 -0
  18. data/lib/source/master/controllers/master_list_controller.rb +101 -0
  19. data/lib/source/master/master_db_data_source.rb +65 -0
  20. data/lib/source/master/ui/master_input_form.rb +72 -0
  21. data/lib/source/master/ui/master_list_view.rb +163 -0
  22. data/lib/source/models/customer.rb +37 -0
  23. data/lib/source/models/master.rb +32 -0
  24. data/lib/source/models/product.rb +31 -0
  25. data/lib/source/models/student.rb +102 -0
  26. data/lib/source/models/student_base.rb +100 -0
  27. data/lib/source/models/student_short.rb +50 -0
  28. data/lib/source/state_holders/list_state_notifier.rb +47 -0
  29. data/lib/source/util/logger_holder.rb +24 -0
  30. data/sig/jewerly_system.rbs +4 -0
  31. metadata +86 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6baa63ffbdf645f0c3a26a53c12722ee6cce910fb3d3d4f50ceb5a998bf25125
4
+ data.tar.gz: d5a49e77077e62f9690c423a2397a9c67d01a1a84178a5e2a919b4fb763a9cd8
5
+ SHA512:
6
+ metadata.gz: a7d70e10a78a22efe3da4168233daf03df6922e01c5aef84d2e11ddda8c0a5e196da4ead932f1b15aa346de73425dc86cca032f5fae88ef6dc6bccccc3f0076e
7
+ data.tar.gz: b6f32dbbfc12db4604b7ad5576a67e8613a9264547e7f9271e62cf869655679af984d1fec4a31e2ca7f9774427ecbf8c20e0c1ddf3903cf5f8401e4708742848
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at delta.null@vk.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "mysql2"
6
+ gem "glimmer-dsl-libui",'~> 0.7.4'
7
+ gem 'win32api'
8
+ gem "minitest"
9
+ gem 'rubocop', group: 'development'
10
+ gem 'rubbish_code', '~> 0.1.3'
11
+ gem 'sinatra', '~> 3.0', '>= 3.0.6'
12
+ gem 'thin', '~> 1.8', '>= 1.8.2'
13
+ gem 'mc_delta'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 NullExp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1 @@
1
+ ![9bm](https://user-images.githubusercontent.com/96076243/218162066-5df24062-497f-4d8b-a9b2-5612afd68f07.gif)
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/jewerly_system/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jewerly_system"
7
+ spec.version = JewerlySystem::VERSION
8
+ spec.authors = ["Jake Epps"]
9
+ spec.email = ["nullexp.team@gmail.com"]
10
+ spec.summary = "Jewerly App"
11
+ spec.description = "А gem that allows you to get pass for patterns"
12
+ spec.homepage = "https://github.com/Jakepps/Ruby_Moment"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 3.2.0"
15
+ spec.add_dependency 'mysql2'
16
+ spec.files = Dir.glob("**/*")
17
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JewerlySystem
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "jewerly_system/version"
4
+
5
+ module JewerlySystem
6
+ Dir[File.dirname(__FILE__) + '/source/**/*.rb'].each { |file|
7
+ puts file
8
+ require file
9
+ }
10
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'win32api'
4
+
5
+ class CustomerInputFormControllerCreate
6
+ def initialize(parent_controller)
7
+ @parent_controller = parent_controller
8
+ @publisher_rep = CustomerDBDataSource.new
9
+ end
10
+
11
+ def set_view(view)
12
+ @view = view
13
+ end
14
+
15
+ def on_view_created
16
+ # begin
17
+ # @student_rep = StudentRepository.new(DBSourceAdapter.new)
18
+ # rescue Mysql2::Error::ConnectionError
19
+ # on_db_conn_error
20
+ # end
21
+ end
22
+
23
+ def process_fields(fields)
24
+ begin
25
+ puts fields
26
+ item = Customer.new(-1, *fields.values)
27
+ puts item
28
+ item = @publisher_rep.add(item)
29
+ @parent_controller.state_notifier.add(item)
30
+ @view.close
31
+ rescue ArgumentError => e
32
+ api = Win32API.new('user32', 'MessageBox', ['L', 'P', 'P', 'L'], 'I')
33
+ api.call(0, e.message, 'Error', 0)
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def on_db_conn_error
40
+ api = Win32API.new('user32', 'MessageBox', ['L', 'P', 'P', 'L'], 'I')
41
+ api.call(0, "No connection to DB", "Error", 0)
42
+ @view.close
43
+ end
44
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'win32api'
4
+
5
+ class CustomerInputFormControllerEdit
6
+ def initialize(parent_controller, item)
7
+ @parent_controller = parent_controller
8
+ @item = item
9
+ @publisher_rep = CustomerDBDataSource.new
10
+ end
11
+
12
+ def set_view(view)
13
+ @view = view
14
+ end
15
+
16
+ def on_view_created
17
+ # begin
18
+ # @student_rep = StudentRepository.new(DBSourceAdapter.new)
19
+ # rescue Mysql2::Error::ConnectionError
20
+ # on_db_conn_error
21
+ # end
22
+
23
+ # @item = @author_rep.get(@item_id)
24
+ # @view.make_readonly(:git, :telegram, :email, :phone)
25
+ populate_fields(@item)
26
+ end
27
+
28
+ def populate_fields(item)
29
+ @view.set_value(:name, item.name)
30
+ @view.set_value(:email, item.email)
31
+ end
32
+
33
+ def process_fields(fields)
34
+ begin
35
+ item = Customer.new(@item.customer_id, *fields.values)
36
+ item = @publisher_rep.change(item)
37
+ @parent_controller.state_notifier.replace(@item, item)
38
+ @view.close
39
+ rescue ArgumentError => e
40
+ api = Win32API.new('user32', 'MessageBox', ['L', 'P', 'P', 'L'], 'I')
41
+ api.call(0, e.message, 'Error', 0)
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ def on_db_conn_error
48
+ api = Win32API.new('user32', 'MessageBox', ['L', 'P', 'P', 'L'], 'I')
49
+ api.call(0, "No connection to DB", "Error", 0)
50
+ @view.close
51
+ end
52
+ end
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ require './jew/state_holders/list_state_notifier'
4
+ require_relative '../ui/customer_input_form'
5
+ require_relative 'customer_input_form_controller_create.rb'
6
+ require_relative 'customer_input_form_controller_edit'
7
+ require_relative '../customer_db_data_source'
8
+ require 'win32api'
9
+
10
+ class CustomerListController
11
+
12
+ attr_reader :state_notifier
13
+ def initialize(view)
14
+ LoggerHolder.instance.debug('CustomerListController: init start')
15
+ @view = view
16
+ @state_notifier = ListStateNotifier.new
17
+ @state_notifier.add_listener(@view)
18
+ @publisher_rep = CustomerDBDataSource.new
19
+
20
+ @sort_columns = %w[CustomerID Name Email]
21
+ @sort_by = @sort_columns.first
22
+
23
+ @email_filter_columns = [nil, true, false]
24
+ @email_filter = @email_filter_columns.first
25
+ LoggerHolder.instance.debug('CustomerListController: init done')
26
+ end
27
+
28
+
29
+
30
+ def on_view_created
31
+ # begin
32
+ # @student_rep = StudentRepository.new(DBSourceAdapter.new)
33
+ # rescue Mysql2::Error::ConnectionError
34
+ # on_db_conn_error
35
+ # end
36
+ end
37
+
38
+ def show_view
39
+ @view.create.show
40
+ end
41
+
42
+ def show_modal_add
43
+ LoggerHolder.instance.debug('CustomerListController: showing modal (add)')
44
+ controller = CustomerInputFormControllerCreate.new(self)
45
+ view = CustomerInputForm.new(controller)
46
+ controller.set_view(view)
47
+ view.create.show
48
+ end
49
+
50
+ def show_modal_edit(current_page, per_page, selected_row)
51
+ # item_num = (current_page - 1) * per_page + selected_row
52
+
53
+ item = @state_notifier.get(selected_row)
54
+
55
+ controller = CustomerInputFormControllerEdit.new(self, item)
56
+ view = CustomerInputForm.new(controller)
57
+ controller.set_view(view)
58
+ view.create.show
59
+ end
60
+
61
+ def delete_selected(current_page, per_page, selected_row)
62
+ begin
63
+ LoggerHolder.instance.debug('CustomerListController: deleting selected master')
64
+ item = @state_notifier.get(selected_row)
65
+ @publisher_rep.delete(item.customer_id)
66
+ @state_notifier.delete(item)
67
+ rescue
68
+ api = Win32API.new('user32', 'MessageBox', ['L', 'P', 'P', 'L'], 'I')
69
+ api.call(0, "You cannot delete the customer because it is associated with some product", "Error", 0)
70
+ end
71
+ end
72
+
73
+ def refresh_data(page, per_page)
74
+ LoggerHolder.instance.debug('CustomerListController: refreshing data...')
75
+ items = @publisher_rep.get_list(per_page, page, @sort_by, 'ASC', @email_filter)
76
+ @state_notifier.set_all(items)
77
+ @view.update_student_count(@publisher_rep.count)
78
+ end
79
+
80
+ def sort(page, per_page, sort_index)
81
+ LoggerHolder.instance.debug('CustomerListController: filter start...')
82
+ @sort_by = @sort_columns[sort_index]
83
+ refresh_data(page, per_page)
84
+ LoggerHolder.instance.debug('CustomerListController: filter end.')
85
+ end
86
+
87
+ def filter_email(page, per_page, filter_index)
88
+ LoggerHolder.instance.debug('CustomerListController: filter start...')
89
+ @email_filter = @email_filter_columns[filter_index]
90
+ refresh_data(page, per_page)
91
+ LoggerHolder.instance.debug('CustomerListController: filter end.')
92
+ end
93
+
94
+
95
+ private
96
+
97
+ def on_db_conn_error(error)
98
+ LoggerHolder.instance.error('CustomerListController: DB connection error:')
99
+ LoggerHolder.instance.error(error.message)
100
+ api = Win32API.new('user32', 'MessageBox', ['L', 'P', 'P', 'L'], 'I')
101
+ api.call(0, "No connection to DB", "Error", 0)
102
+ exit(false)
103
+ end
104
+ end
@@ -0,0 +1,63 @@
1
+ require 'mysql2'
2
+ require_relative '../data_sources/db_client'
3
+ require_relative '../models/customer'
4
+
5
+ class CustomerDBDataSource
6
+ def initialize
7
+ @client = DBClient.instance
8
+ end
9
+
10
+ def add(customer)
11
+ query = "INSERT INTO Customer (Name, Email) VALUES ('#{customer.name}', #{customer.email.nil? ? 'NULL' : "'#{customer.email}'"})"
12
+ @client.query(query)
13
+ customer_id = @client.last_id
14
+ get(customer_id)
15
+ end
16
+
17
+ def change(customer)
18
+ query = "UPDATE Customer SET Name='#{customer.name}', Email=#{customer.email.nil? ? 'NULL' : "'#{customer.email}'"} WHERE CustomerID=#{customer.customer_id}"
19
+ @client.query(query)
20
+ get(customer.customer_id)
21
+ end
22
+
23
+ def delete(id)
24
+ query = "DELETE FROM Customer WHERE CustomerID=#{id}"
25
+ @client.query(query)
26
+ end
27
+
28
+ def get(id)
29
+ query = "SELECT * FROM Customer WHERE CustomerID=#{id}"
30
+ result = @client.query(query).first
31
+ if result
32
+ Customer.new(result[:'CustomerID'], result[:'Name'], result[:'Email'])
33
+ else
34
+ nil
35
+ end
36
+ end
37
+
38
+ def get_list(page_size, page_num, sort_field, sort_direction, has_email = nil)
39
+ offset = (page_num - 1) * page_size
40
+ query = "SELECT * FROM Customer"
41
+
42
+ if has_email == true
43
+ query += " WHERE Email IS NOT NULL"
44
+ elsif has_email == false
45
+ query += " WHERE Email IS NULL"
46
+ end
47
+
48
+ query += " ORDER BY #{sort_field} #{sort_direction} LIMIT #{page_size} OFFSET #{offset}"
49
+
50
+ results = @client.query(query)
51
+ customers = []
52
+ results.each do |result|
53
+ customers << Customer.new(result[:'CustomerID'], result[:'Name'], result[:'Email'])
54
+ end
55
+ customers
56
+ end
57
+
58
+ def count
59
+ query = "SELECT COUNT(*) FROM Customer"
60
+ result = @client.query(query).first
61
+ result[:'COUNT(*)']
62
+ end
63
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+ require_relative '../controllers/customer_input_form_controller_create.rb'
5
+ require './jew/models/master'
6
+ require 'win32api'
7
+
8
+ class CustomerInputForm
9
+ include Glimmer
10
+
11
+ def initialize(controller, existing_student = nil)
12
+ @item = existing_student.to_hash unless existing_student.nil?
13
+ @controller = controller
14
+ @entries = {}
15
+ end
16
+
17
+ def on_create
18
+ @controller.on_view_created
19
+ end
20
+
21
+ def create
22
+ @root_container = window('Заказчик', 300, 70) {
23
+ resizable false
24
+
25
+ vertical_box {
26
+ @student_form = form {
27
+ stretchy false
28
+
29
+ fields = [[:name, 'Название'], [:email, 'Почта']]
30
+
31
+ fields.each do |field|
32
+ @entries[field[0]] = entry {
33
+ label field[1]
34
+ }
35
+ end
36
+ }
37
+
38
+ button('Сохранить') {
39
+ stretchy false
40
+
41
+ on_clicked {
42
+ values = @entries.transform_values { |v| v.text.force_encoding("utf-8").strip }
43
+ values.transform_values! { |v| v.empty? ? nil : v}
44
+
45
+ @controller.process_fields(values)
46
+ LoggerHolder.instance.debug('CustomerInputForm: adding/edit customer to DB')
47
+ }
48
+ }
49
+ }
50
+ }
51
+ on_create
52
+ @root_container
53
+ end
54
+
55
+ def set_value(field, value)
56
+ return unless @entries.include?(field)
57
+
58
+ @entries[field].text = value
59
+ end
60
+
61
+ def make_readonly(*fields)
62
+ fields.each do |field|
63
+ @entries[field].read_only = true
64
+ end
65
+ end
66
+
67
+ def close
68
+ @root_container.destroy
69
+ end
70
+ end
@@ -0,0 +1,159 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+ require_relative '../controllers/customer_list_controller'
5
+ require_relative 'customer_input_form'
6
+
7
+ class CustomerListView
8
+ include Glimmer
9
+
10
+ PAGE_SIZE = 20
11
+
12
+ def initialize
13
+ @controller = CustomerListController.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, PAGE_SIZE)
21
+ end
22
+
23
+ def update(customer)
24
+ @items = []
25
+
26
+ i = 0
27
+ item_num = 0
28
+ customer.each do |publisher|
29
+ i += 1
30
+ item_num = ((@current_page - 1) * PAGE_SIZE) + i
31
+ @items << Struct.new(:№, :id, :название, :почта).new(item_num, publisher.customer_id, publisher.name, publisher.email)
32
+ end
33
+
34
+ @table.model_array = @items
35
+ @page_label.text = "#{@current_page} / #{(@total_count / PAGE_SIZE.to_f).ceil}"
36
+ end
37
+
38
+ def update_student_count(new_cnt)
39
+ @total_count = new_cnt
40
+ @page_label.text = "#{@current_page} / #{(@total_count / PAGE_SIZE.to_f).ceil}"
41
+ end
42
+
43
+ def create
44
+
45
+ root_container = horizontal_box {
46
+ # Секция 1
47
+ vertical_box {
48
+ stretchy false
49
+
50
+ vertical_box {
51
+ stretchy false
52
+
53
+ label {
54
+ text 'Почта'
55
+ }
56
+ combobox { |c|
57
+ items ['Не важно','Есть','Нет']
58
+ selected 0
59
+ on_selected do
60
+ @controller.filter_email(@current_page, PAGE_SIZE, c.selected)
61
+ end
62
+ }
63
+
64
+ label {
65
+ text 'Сортировка'
66
+ }
67
+ combobox { |c|
68
+ items ['ID','Название','Почта']
69
+ selected 0
70
+ on_selected do
71
+ @controller.sort(@current_page, PAGE_SIZE, c.selected)
72
+ end
73
+ }
74
+ }
75
+
76
+
77
+ }
78
+
79
+ # Секция 2
80
+ vertical_box {
81
+ @table = refined_table(
82
+ table_editable: false,
83
+ filter: lambda do |row_hash, query|
84
+ utf8_query = query.force_encoding("utf-8")
85
+ row_hash['Имя мастера'].include?(utf8_query)
86
+ end,
87
+ table_columns: {
88
+ '№' => :text,
89
+ 'ID' => :text,
90
+ 'Название' => :text,
91
+ 'Почта' => :text,
92
+ },
93
+ per_page: PAGE_SIZE,
94
+
95
+ )
96
+
97
+ @pages = horizontal_box {
98
+ stretchy false
99
+
100
+ button("<") {
101
+ stretchy true
102
+
103
+ on_clicked do
104
+ @current_page = [@current_page - 1, 1].max
105
+ @controller.refresh_data(@current_page, PAGE_SIZE)
106
+ end
107
+
108
+ }
109
+ @page_label = label("...") { stretchy false }
110
+ button(">") {
111
+ stretchy true
112
+
113
+ on_clicked do
114
+ @current_page = [@current_page + 1, (@total_count / PAGE_SIZE.to_f).ceil].min
115
+ @controller.refresh_data(@current_page, PAGE_SIZE)
116
+ end
117
+ }
118
+ }
119
+ }
120
+
121
+ # Секция 3
122
+ vertical_box {
123
+ stretchy false
124
+
125
+ button('Добавить') {
126
+ stretchy false
127
+
128
+ on_clicked {
129
+ @controller.show_modal_add
130
+ }
131
+ }
132
+ button('Изменить') {
133
+ stretchy false
134
+
135
+ on_clicked {
136
+ @controller.show_modal_edit(@current_page, PAGE_SIZE, @table.selection) unless @table.selection.nil?
137
+ }
138
+ }
139
+ button('Удалить') {
140
+ stretchy false
141
+
142
+ on_clicked {
143
+ @controller.delete_selected(@current_page, PAGE_SIZE, @table.selection) unless @table.selection.nil?
144
+ @controller.refresh_data(@current_page, PAGE_SIZE)
145
+ }
146
+ }
147
+ button('Обновить') {
148
+ stretchy false
149
+
150
+ on_clicked {
151
+ @controller.refresh_data(@current_page, PAGE_SIZE)
152
+ }
153
+ }
154
+ }
155
+ }
156
+ on_create
157
+ root_container
158
+ end
159
+ end