card-mod-flag 0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 453be2f171c334431867586bd7bc246d9a6487483dcb5b4848404db4122e67b1
4
+ data.tar.gz: a9fea2ba030a6975048fd7e3c2f7c508dcaf6f60fbfc8ccecb556c3022590b19
5
+ SHA512:
6
+ metadata.gz: f54d7efaa75d147a83058bd5c72e070d883633489ccb1cb3ef820619aab23753b1cfbeef3e1a6ce93cb83d4044c8c6853eb53cde22f0839d4a4a1aa7987a6da2
7
+ data.tar.gz: f45b282f37f21aad12b6bf69c7c16de53e3a72cb0a6167c8f40a6ced94cb783156903cdba25c59bb32a8337a8b5d1053a75ca9fafb9b93cde4782642cc6c1435
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ <!--
2
+ # @title README - mod: flag
3
+ -->
4
+ # flag
@@ -0,0 +1,21 @@
1
+ delegate :lookup_card, :lookup, :lookup_columns, to: :flag_card
2
+
3
+ def flag_card
4
+ left
5
+ end
6
+
7
+ event :update_flaggable_lookup_field, :finalize, changed: :content, when: :lookup? do
8
+ lookup_field_update do
9
+ lookup.refresh(*Array.wrap(lookup_columns))
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def lookup?
16
+ lookup_card.respond_to? :lookup
17
+ end
18
+
19
+ def lookup_field_update
20
+ yield unless lookup_card.action.in? %i[create delete]
21
+ end
@@ -0,0 +1,15 @@
1
+ def open_flag_cards
2
+ new? ? [] : Card.search(open_flag_cql)
3
+ end
4
+
5
+ def count_open_flags
6
+ new? ? 0 : Card.search(open_flag_cql.merge(return: :count))
7
+ end
8
+
9
+ private
10
+
11
+ def open_flag_cql
12
+ { type: :flag,
13
+ right_plus: [:subject, refer_to: id],
14
+ not: { right_plus: [:status, { eq: "closed" }] } }
15
+ end
data/set/right/flag.rb ADDED
@@ -0,0 +1,10 @@
1
+ assign_type :search_type
2
+
3
+ def virtual?
4
+ new?
5
+ end
6
+
7
+ def cql_content
8
+ { type: :flag,
9
+ right_plus: [:subject, refer_to: "_left"] }
10
+ end
@@ -0,0 +1,4 @@
1
+ .pe-3
2
+ = card.flag_type_card.first_name
3
+ %em.fw-normal
4
+ = "(#{card.status})"
data/set/type/flag.rb ADDED
@@ -0,0 +1,59 @@
1
+ FIELDS = %i[flag_type status subject discussion].freeze
2
+ REQUIRED_FIELDS = FIELDS - [:status]
3
+
4
+ card_accessor :flag_type, type: :pointer
5
+ card_accessor :subject, type: :pointer
6
+ card_accessor :status, type: :pointer # , default_content: "open"
7
+ card_accessor :discussion
8
+
9
+ REQUIRED_FIELDS.each { |fld| require_field fld }
10
+
11
+ format :html do
12
+ # LOCALIZE
13
+ before(:new) { voo.title = "Flag a problem" }
14
+ before(:new_fields) { voo.buttons_view = :new_in_modal_buttons }
15
+
16
+ def edit_fields
17
+ card.new? ? REQUIRED_FIELDS : FIELDS
18
+ end
19
+
20
+ def new_form_opts
21
+ super.merge "data-slotter-mode": "update-origin", class: "_close-modal"
22
+ end
23
+
24
+ mini_bar_cols 6, 6
25
+
26
+ view :bar_left, template: :haml
27
+ view(:bar_middle, wrap: :em) { field_nest :status, view: :core }
28
+ view(:bar_right) { render_credit }
29
+ view :bar_bottom do
30
+ field_nest :discussion, view: :titled, show: :comment_box
31
+ end
32
+
33
+ view :credit do
34
+ wrap_with :div, class: "credit text-muted text-end" do
35
+ ["Flagged", create_date, create_by_whom].join " "
36
+ end
37
+ end
38
+
39
+ def create_date
40
+ "#{render :updated_at} ago"
41
+ end
42
+
43
+ def create_by_whom
44
+ "by #{link_to_card card.creator}"
45
+ end
46
+ end
47
+
48
+ # the following only matter if the flagged content uses lookups
49
+ def lookup_card
50
+ subject_card&.first_card
51
+ end
52
+
53
+ def lookup
54
+ lookup_card&.lookup
55
+ end
56
+
57
+ def lookup_columns
58
+ [:open_flags]
59
+ end
@@ -0,0 +1,5 @@
1
+ format :html do
2
+ def edit_fields
3
+ [:description]
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ format :html do
2
+ before :edit_in_form do
3
+ voo.title = "Tell us more"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ include_set Abstract::IdList
2
+
3
+ def ok_item_types
4
+ :flag_type
5
+ end
6
+
7
+ format :html do
8
+ # LOCALIZE
9
+ before :title do
10
+ voo.title = "Flag Type"
11
+ end
12
+
13
+ def input_type
14
+ :radio
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ include_set Abstract::FlagField
2
+
3
+ # LOCALIZE
4
+ def option_names
5
+ %w[open closed]
6
+ end
7
+
8
+ def default_content
9
+ "open"
10
+ end
11
+
12
+ format :html do
13
+ before :title do
14
+ voo.title = "Status"
15
+ end
16
+
17
+ def input_type
18
+ :radio
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ include_set Abstract::FlagField
2
+
3
+ format :html do
4
+ def input_type
5
+ :hidden
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: card-mod-flag
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ platform: ruby
6
+ authors:
7
+ - Philipp Kühl
8
+ - Ethan McCutchen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2023-05-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: card
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ description: ''
29
+ email:
30
+ - info@decko.org
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - README.md
36
+ - set/abstract/flag_field.rb
37
+ - set/abstract/flaggable.rb
38
+ - set/right/flag.rb
39
+ - set/type/flag.rb
40
+ - set/type/flag/bar_left.haml
41
+ - set/type/flag_type.rb
42
+ - set/type_plus_right/flag/discussion.rb
43
+ - set/type_plus_right/flag/flag_type.rb
44
+ - set/type_plus_right/flag/status.rb
45
+ - set/type_plus_right/flag/subject.rb
46
+ homepage: http://decko.org
47
+ licenses:
48
+ - GPL-3.0
49
+ metadata:
50
+ card-mod: flag
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '2.5'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubygems_version: 3.2.33
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: flag
70
+ test_files: []