checkoff 0.23.0 → 0.24.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/checkoff/internal/search_url/custom_field_param_converter.rb +1 -0
- data/lib/checkoff/internal/search_url/custom_field_variant.rb +18 -12
- data/lib/checkoff/internal/task_selector_evaluator.rb +27 -11
- data/lib/checkoff/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26474f8f2f94c75d46d16eadd8c773a22d139d56e0d4bcaaae4c698519e8fa89
|
4
|
+
data.tar.gz: fc1b3a92a5736360fec289c1f2c156bc6570ad465fe8ecfdaa63a1b5a10cef5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80a903a43039264b205cb4ae61f4637360d8a9b4db4cf47062fd4d8e0ed127f420e6da5baebb30c2cbde792261c2265133157f45a19f7cfea8f0577b862327ac
|
7
|
+
data.tar.gz: f6a30feeda861f28f96bb8a7a6b38d68bd3a4042bf21b7521c4382c1b2107aeee8a04c405d5f79fe7fec0acfe27bce778f48ff93c00d27bc552b3f0e531a0359
|
data/Gemfile.lock
CHANGED
@@ -49,6 +49,7 @@ module Checkoff
|
|
49
49
|
'is_not' => CustomFieldVariant::IsNot,
|
50
50
|
'less_than' => CustomFieldVariant::LessThan,
|
51
51
|
'greater_than' => CustomFieldVariant::GreaterThan,
|
52
|
+
'doesnt_contain_any' => CustomFieldVariant::DoesntContainAny,
|
52
53
|
}.freeze
|
53
54
|
|
54
55
|
def convert_single_custom_field_params(gid, single_custom_field_params)
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Checkoff
|
4
4
|
module Internal
|
5
5
|
module SearchUrl
|
6
|
+
# https://developers.asana.com/docs/search-tasks-in-a-workspace
|
6
7
|
module CustomFieldVariant
|
7
8
|
# base class for handling different custom_field_#{gid}.variant params
|
8
9
|
class CustomFieldVariant
|
@@ -48,28 +49,33 @@ module Checkoff
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
52
|
+
# This is used in the UI for select fields
|
53
|
+
#
|
51
54
|
# custom_field_#{gid}.variant = 'is_not'
|
52
55
|
class IsNot < CustomFieldVariant
|
53
56
|
def convert
|
54
|
-
|
55
|
-
when ["custom_field_#{gid}.selected_options"]
|
56
|
-
convert_single_custom_field_is_not_params_selected_options
|
57
|
-
else
|
58
|
-
raise "Teach me how to handle #{remaining_params}"
|
59
|
-
end
|
60
|
-
end
|
57
|
+
selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
|
61
58
|
|
62
|
-
|
59
|
+
[{ "custom_fields.#{gid}.is_set" => 'true' },
|
60
|
+
['not',
|
61
|
+
['custom_field_gid_value_contains_any_gid',
|
62
|
+
gid,
|
63
|
+
selected_options]]]
|
64
|
+
end
|
65
|
+
end
|
63
66
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
+
# This is used in the UI for multi-select fields
|
68
|
+
#
|
69
|
+
# custom_field_#{gid}.variant = 'doesnt_contain_any'
|
70
|
+
class DoesntContainAny < CustomFieldVariant
|
71
|
+
def convert
|
72
|
+
selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
|
67
73
|
|
68
74
|
[{ "custom_fields.#{gid}.is_set" => 'true' },
|
69
75
|
['not',
|
70
76
|
['custom_field_gid_value_contains_any_gid',
|
71
77
|
gid,
|
72
|
-
selected_options
|
78
|
+
selected_options]]]
|
73
79
|
end
|
74
80
|
end
|
75
81
|
|
@@ -105,24 +105,40 @@ module Checkoff
|
|
105
105
|
end
|
106
106
|
|
107
107
|
matched_custom_field = custom_fields.find { |data| data.fetch('gid') == custom_field_gid }
|
108
|
-
|
108
|
+
if matched_custom_field.nil?
|
109
|
+
raise "Could not find custom field with gid #{custom_field_gid} in #{task.gid} with #{custom_fields}"
|
110
|
+
end
|
109
111
|
|
110
112
|
matched_custom_field
|
111
113
|
end
|
112
114
|
|
113
|
-
def
|
114
|
-
|
115
|
+
def pull_enum_values(custom_field)
|
116
|
+
resource_subtype = custom_field.fetch('resource_subtype')
|
117
|
+
case resource_subtype
|
118
|
+
when 'enum'
|
119
|
+
[custom_field.fetch('enum_value')]
|
120
|
+
when 'multi_enum'
|
121
|
+
custom_field.fetch('multi_enum_values')
|
122
|
+
else
|
123
|
+
raise "Teach me how to handle resource_subtype #{resource_subtype}"
|
124
|
+
end
|
125
|
+
end
|
115
126
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
127
|
+
def find_gids(custom_field, enum_value)
|
128
|
+
if enum_value.nil?
|
129
|
+
[]
|
130
|
+
else
|
131
|
+
raise "Unexpected enabled value on custom field: #{custom_field}" if enum_value.fetch('enabled') == false
|
122
132
|
|
123
|
-
|
133
|
+
[enum_value.fetch('gid')]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def pull_custom_field_values_gids(task, custom_field_gid)
|
138
|
+
custom_field = pull_custom_field_or_raise(task, custom_field_gid)
|
139
|
+
pull_enum_values(custom_field).flat_map do |enum_value|
|
140
|
+
find_gids(custom_field, enum_value)
|
124
141
|
end
|
125
|
-
actual_custom_field_values_gids
|
126
142
|
end
|
127
143
|
end
|
128
144
|
|
data/lib/checkoff/version.rb
CHANGED