Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ slug: inbox
if conversations.total_entries > 0
if current_conversation and current_conversation.participants == blank
graphql participants = 'modules/user/profiles/search', ids: current_conversation.participant_ids
hash_assign current_conversation['participants'] = participants.records.results
assign current_conversation.participants = participants.records.results
endif

render 'modules/chat/inbox', current_conversation: current_conversation, conversations: conversations, current_profile: current_profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
function conversation = 'modules/chat/lib/queries/conversations/find_by_participant', id: room_id, participant_id: current_profile.id, include_messages: null
if conversation
assign message_safe = context.params.message | raw_escape_string
assign object = '{}' | parse_json
hash_assign object['conversation_id'] = conversation.id
hash_assign object['autor_id'] = current_profile.id
hash_assign object['message'] = message_safe
assign object = { "conversation_id": conversation.id, "autor_id": current_profile.id, "message": message_safe }
function message = 'modules/chat/lib/commands/messages/create', object: object
if message.valid != true
log message, 'ERROR receive message'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<script type="module" defer src="{{ 'modules/chat/js/pos-chat.js' | asset_url }}"></script>

<!-- message templates -->
{% assign dummy_message = '{ "message": "", "created_at": null }' | parse_json %}
{% assign dummy_message = { "message": "", "created_at": null } %}
<template id="pos-chat-template-message-received">
{% render 'modules/chat/message', message: dummy_message, authored: false, timezone: null %}
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% liquid
assign data = '{}' | parse_json
hash_assign data['participant_ids'] = object.participant_ids
hash_assign data['participant_read_ids'] = current_profile.id
assign data = { "participant_ids": object.participant_ids, "participant_read_ids": current_profile.id }

return data
%}
%}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% liquid
assign c = '{ "errors": {}, "valid": true }' | parse_json
assign c = { "errors": {}, "valid": true }

function c = 'modules/core/validations/presence', c: c, object: object, field_name: 'participant_ids'
function c = 'modules/core/validations/length', c: c, object: object, field_name: 'participant_ids', minimum: 2, allow_blank: null
function c = 'modules/core/validations/presence', c: c, object: object, field_name: 'participant_read_ids'

hash_assign object['valid'] = c.valid
hash_assign object['errors'] = c.errors
assign object.valid = c.valid
assign object.errors = c.errors

return object
%}
%}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
function conversation = 'modules/chat/lib/queries/conversations/find_by_participants', participant_ids: object.participant_ids, include_messages: true
unless conversation
function conversation = 'modules/chat/lib/commands/conversations/create', object: object, current_profile: current_profile
hash_assign conversation['created'] = true
assign conversation.created = true
endunless
endif

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{% liquid
assign participants = '[]' | parse_json | add_to_array: current_profile.id | add_to_array: object['to_id'] | uniq | compact | sort
assign data = '{}' | parse_json
hash_assign data['participant_ids'] = participants
hash_assign data['conversation_id'] = object.conversation_id
assign participants = [current_profile.id, object.to_id] | uniq | compact | sort
assign data = { "participant_ids": participants, "conversation_id": object.conversation_id }

return data
%}
%}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

assign types = object.participants | map: 'type' | uniq
if types.size == 1 and types.first == 'profile'
hash_assign object['valid'] = false
assign object.valid = false
endif
endcomment

return object
%}
%}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{% liquid
assign data = '{}' | parse_json
hash_assign data['id'] = conversation.id
hash_assign data['participant_read_ids'] = conversation.participant_read_ids
hash_assign data['participant_id'] = participant_id
assign data = { "id": conversation.id, "participant_read_ids": conversation.participant_read_ids, "participant_id": participant_id }

return data
%}
%}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% liquid
assign c = '{ "errors": {}, "valid": true }' | parse_json
assign c = { "errors": {}, "valid": true }

function c = 'modules/core/validations/presence', c: c, object: object, field_name: 'id'
function c = 'modules/core/validations/presence', c: c, object: object, field_name: 'participant_id'

hash_assign object['valid'] = c.valid
hash_assign object['errors'] = c.errors
assign object.valid = c.valid
assign object.errors = c.errors

return object
%}
%}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% liquid
assign data = '{}' | parse_json
hash_assign data['id'] = conversation.id
hash_assign data['participant_read_ids'] = current_profile.id
assign data = { "id": conversation.id, "participant_read_ids": current_profile.id }

return data
%}
%}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{% liquid
assign c = '{ "errors": {}, "valid": true }' | parse_json
assign c = { "errors": {}, "valid": true }

function c = 'modules/core/validations/presence', c: c, object: object, field_name: 'id'
function c = 'modules/core/validations/presence', c: c, object: object, field_name: 'participant_read_ids'

hash_assign object['valid'] = c.valid
hash_assign object['errors'] = c.errors
assign object.valid = c.valid
assign object.errors = c.errors

return object
%}
%}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{% liquid
assign data = '{}' | parse_json
hash_assign data['conversation_id'] = object.conversation_id
hash_assign data['autor_id'] = object.autor_id
hash_assign data['message'] = object.message
assign data = { "conversation_id": object.conversation_id, "autor_id": object.autor_id, "message": object.message }

return data
%}
%}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% liquid
assign c = '{ "errors": {}, "valid": true }' | parse_json
assign c = { "errors": {}, "valid": true }

function c = 'modules/core/validations/presence', c: c, object: object, field_name: 'conversation_id'
function c = 'modules/core/validations/presence', c: c, object: object, field_name: 'autor_id'
function c = 'modules/core/validations/presence', c: c, object: object, field_name: 'message'

hash_assign object['valid'] = c.valid
hash_assign object['errors'] = c.errors
assign object.valid = c.valid
assign object.errors = c.errors

return object
%}
%}
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@

assign conversation = r.conversations.results.first

assign participants = '[]' | parse_json
assign participants = []


# platformos-check-disable GraphqlInForLoop
for participant_id in conversation.participant_ids
function profile = 'modules/user/queries/profiles/find', id: participant_id, user_id: null, uuid: null, first_name: null, last_name: null
assign participants = participants | add_to_array: profile
assign participants << profile
endfor
# platformos-check-enable GraphqlInForLoop

hash_assign conversation['participants'] = participants
assign conversation.participants = participants

return conversation
%}
%}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
assign conversation = r.conversations.results.first

if conversation
assign participants = '[]' | parse_json
assign participants = []

for participant_id in conversation.participant_ids
function profile = 'modules/user/queries/profiles/find', id: participant_id, user_id: null, uuid: null, first_name: null, last_name: null
assign participants = participants | add_to_array: profile
assign participants << profile
endfor

hash_assign conversation['participants'] = participants
assign conversation.participants = participants
endif

return conversation
%}
%}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
assign conversation = r.conversations.results.first

if conversation
assign participants = '[]' | parse_json
assign participants = []

for participant_id in conversation.participant_ids
function profile = 'modules/user/queries/profiles/find', id: participant_id, user_id: null, uuid: null, first_name: null, last_name: null
assign participants = participants | add_to_array: profile
assign participants << profile
endfor

hash_assign conversation['participants'] = participants
assign conversation.participants = participants
endif

return conversation
%}
%}
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
graphql r = 'modules/chat/conversations/search_by_message', limit: limit, page: page, participant_id: participant_id, message: message

assign result = r.conversations
assign conversations = '[]' | parse_json
assign conversations = []

for conversation in result.results
assign participants = '[]' | parse_json
assign participants = []

for participant_id in conversation.participant_ids
function profile = 'modules/user/queries/profiles/find', id: participant_id, user_id: null, uuid: null, first_name: null, last_name: null
assign participants = participants | add_to_array: profile
assign participants << profile
endfor

hash_assign conversation['participants'] = participants
assign conversations = conversations | add_to_array: conversation
assign conversation.participants = participants
assign conversations << conversation
endfor

hash_assign result['results'] = conversations
assign result.results = conversations

return result
%}
%}
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
graphql r = 'modules/chat/conversations/search', limit: limit, page: page, participant_id: participant_id

assign result = r.conversations
assign conversations = '[]' | parse_json
assign conversations = []

for conversation in result.results
assign participants = '[]' | parse_json
assign participants = []

for participant_id in conversation.participant_ids
function profile = 'modules/user/queries/profiles/find', id: participant_id, user_id: null, uuid: null, first_name: null, last_name: null
assign participants = participants | add_to_array: profile
assign participants << profile
endfor

hash_assign conversation['participants'] = participants
assign conversations = conversations | add_to_array: conversation
assign conversation.participants = participants
assign conversations << conversation
endfor

hash_assign result['results'] = conversations
assign result.results = conversations

return result
%}
%}
6 changes: 3 additions & 3 deletions pos-module-chat/modules/chat/template-values.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "Pos Module Chat",
"machine_name": "chat",
"type": "module",
"version": "1.1.1",
"version": "1.2.0",
"dependencies": {
"core": "^2.0.6",
"core": "^2.1.0",
"profile": "^1.1.1",
"user": "^5.0.4",
"user": "^5.2.0",
"common-styling": "1.11.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1139,9 +1139,9 @@ layout: 'modules/common-styling/style-guide'
for i in (i..10)
assign value = 'value' | append: i
assign label = 'Label for value ' | append: i
assign example_item = '{}' | parse_json | hash_merge: value: value, label: label
assign example_item = { "value": value, "label": label }
assign example_list = example_list | add_to_array: example_item
assign selected = '["value0", "value5", "value6"]' | parse_json
assign selected = ["value0", "value5", "value6"]
endfor
%}
{% render 'modules/common-styling/forms/multiselect', name: 'styleguide-form-multiselect-test-1', id: 'styleguide-form-multiselect-test-1', list: example_list, showFilter: true, combine_selected: true %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% liquid
assign object = '{}' | parse_json
assign object = {}
render 'theme/simple/<%= modelNamePlural %>/new', object: object
%}
%}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
function _ = implementation.path, params_to_modify: params_to_modify, params: params
endfor

assign result = '{}' | parse_json | hash_merge: original_params: original_params
assign result = { "original_params": original_params }
return result
%}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
{% endcomment %}
{% liquid
if merge_to_object
assign results = '{}' | parse_json
assign results = {}
else
assign results = '[]' | parse_json
assign results = []
endif

assign hook = '/hook_' | append: hook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
function _ = implementation.path, params_to_modify: params_to_modify, params: params
endfor

assign result = '{}' | parse_json | hash_merge: original_params: original_params
assign result = { "original_params": original_params }
return result
%}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
{% endcomment %}
{% liquid
if merge_to_object
assign results = '{}' | parse_json
assign results = {}
else
assign results = '[]' | parse_json
assign results = []
endif

assign hook = '/hook_' | append: hook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

assign errors = contract.errors

assign field_errors = errors[field_name] | default: '[]' | parse_json
assign field_errors = errors[field_name] | default: []
assign field_errors = field_errors | add_to_array: msg

hash_assign errors[field_name] = field_errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@

case type
when 'module'
assign modules = '[]' | parse_json
assign modules = []
for module in registry
if module.type == 'module'
assign modules = modules | add_to_array: module
assign modules << module
endif
endfor
return modules
when 'theme'
assign themes = '[]' | parse_json
assign themes = []
for module in registry
if module.type == 'theme'
assign themes = themes | add_to_array: module
assign themes << module
endif
endfor
return themes
Expand Down
Loading
Loading