Class: Labimotion::KlassShareEntity
- Inherits:
-
ApplicationEntity
- Object
- ApplicationEntity
- Labimotion::KlassShareEntity
- Defined in:
- lib/labimotion/entities/klass_share_entity.rb
Overview
One collaborator row in the Share modal. Exposes both the integer level and its label so
the frontend neither hardcodes the numeric mapping nor loses the ordering the integers
carry. The user block mirrors the owner block on GenericKlassEntity, state included —
a share held by a departed user renders greyed out, it is never deleted (the account can
be undeleted, and its shares should come back with it).
Instance Method Summary collapse
Instance Method Details
#permission ⇒ Object
17 18 19 20 |
# File 'lib/labimotion/entities/klass_share_entity.rb', line 17 def value = object. value.is_a?(Integer) ? Labimotion::KlassShare::LEVELS.key(value)&.to_s : value.to_s end |
#permission_level_value ⇒ Object
22 23 24 |
# File 'lib/labimotion/entities/klass_share_entity.rb', line 22 def object.level end |
#user ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/labimotion/entities/klass_share_entity.rb', line 26 def user resolved = [:users]&.[](object.shared_with_id) || Labimotion::OwnerResolver.find(object.shared_with_id) return { id: object.shared_with_id, name: nil, name_abbreviation: nil, state: 'unknown' } if resolved.nil? { id: object.shared_with_id, name: resolved.name, name_abbreviation: resolved.name_abbreviation, state: user_state(resolved) } end |