Class: TranslationCms::Api::Customers::Ticket
- Inherits:
-
Base
- Object
- JsonApiClient::Resource
- Base
- Base
- TranslationCms::Api::Customers::Ticket
show all
- Extended by:
- EnumField::EnumeratedAttribute, HstoreTranslate::Translates
- Includes:
- ActionView::Helpers::TextHelper
- Defined in:
- lib/translation_cms/api/customers/ticket.rb
Constant Summary
collapse
- AVAILABLE_STATES =
%w[created pending in_progress closed follow_up_fail trash
approaching_deadline].freeze
- CLOSED_STATES =
%w[trash closed].freeze
- ACTIVE_STATES =
(AVAILABLE_STATES - CLOSED_STATES).freeze
- TRASH_STATES =
%w[trash].freeze
Instance Method Summary
collapse
Methods inherited from Base
all!, custom_scope!, default_attributes, destroy, dummy_resource!, #method_missing_with_translations_will_change, parsed!, path_with_custom_scope, resource_type!, update
Instance Method Details
#active? ⇒ Boolean
47
48
49
|
# File 'lib/translation_cms/api/customers/ticket.rb', line 47
def active?
ACTIVE_STATES.include? state
end
|
#author_name ⇒ Object
43
44
45
|
# File 'lib/translation_cms/api/customers/ticket.rb', line 43
def author_name
I18n.t :self, scope: [:account, :tickets]
end
|
#closed? ⇒ Boolean
51
52
53
|
# File 'lib/translation_cms/api/customers/ticket.rb', line 51
def closed?
CLOSED_STATES.include? state
end
|
#content_html ⇒ Object
39
40
41
|
# File 'lib/translation_cms/api/customers/ticket.rb', line 39
def content_html
simple_format(description)
end
|
#css_class ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/translation_cms/api/customers/ticket.rb', line 22
def css_class
case state.to_sym
when :in_progress, :follow_up_fail, :approaching_deadline then 'status_progress'
when :closed then 'status_resolved'
when :trash then 'status_closed'
else 'status_new'
end
end
|
#dom_id ⇒ Object
35
36
37
|
# File 'lib/translation_cms/api/customers/ticket.rb', line 35
def dom_id
'initial'
end
|
#from_customer? ⇒ Boolean
31
32
33
|
# File 'lib/translation_cms/api/customers/ticket.rb', line 31
def from_customer?
html_class == 'in'
end
|
#parsed_updated_at ⇒ Object
63
64
65
|
# File 'lib/translation_cms/api/customers/ticket.rb', line 63
def parsed_updated_at
@parsed_updated_at ||= Time.zone.parse(updated_at)
end
|
#state_title ⇒ Object
59
60
61
|
# File 'lib/translation_cms/api/customers/ticket.rb', line 59
def state_title
I18n.t state, scope: [:account, :tickets, :state]
end
|
#trash? ⇒ Boolean
55
56
57
|
# File 'lib/translation_cms/api/customers/ticket.rb', line 55
def trash?
TRASH_STATES.include? state
end
|