Skip to content

Commit

Permalink
Feat(dui3): add new properties to receiver model card (#390)
Browse files Browse the repository at this point in the history
* Add new properties to receiver model card

* Update state correctly from read data at doc init
  • Loading branch information
oguzhankoral authored Sep 11, 2024
1 parent c1b8ec7 commit bc55543
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ def self.update_state(state, resolve_id, data)
model_name = data['modelName']
expired = data['expired']
selected_version_id = data['selectedVersionId']
selected_version_source_app = data['selectedVersionSourceApp']
selected_version_user_id = data['selectedVersionUserId']
latest_version_id = data['latestVersionId']
latest_version_source_app = data['latestVersionSourceApp']
latest_version_user_id = data['latestVersionUserId']
has_dismissed_update_warning = data['hasDismissedUpdateWarning']
baked_object_ids = data['bakedObjectIds'].nil? ? nil : data['bakedObjectIds'].values

receive_card = Cards::ReceiveCard.new(model_card_id, account_id,
project_id, model_id,
project_name, model_name,
selected_version_id, latest_version_id,
selected_version_id, selected_version_source_app, selected_version_user_id,
latest_version_id, latest_version_source_app, latest_version_user_id,
has_dismissed_update_warning, expired, baked_object_ids)
SketchupModel::Dictionary::ModelCardDictionaryHandler
.save_receive_card_to_model(receive_card, state.sketchup_state.sketchup_model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def self.update_state(state, resolve_id)
receive_cards = receive_cards_hash.collect do |id, card|
receive_card = Cards::ReceiveCard.new(id, card['account_id'], card['project_id'], card['model_id'],
card['project_name'], card['model_name'], card['selected_version_id'],
card['latest_version_id'], card['has_dismissed_update_warning'],
card['selected_version_source_app'], card['selected_version_user_id'],
card['latest_version_id'], card['latest_version_source_app'],
card['latest_version_user_id'], card['has_dismissed_update_warning'],
card['expired'], card['baked_object_ids'])

new_speckle_state = state.speckle_state.with_receive_card(receive_card)
Expand All @@ -64,7 +66,11 @@ def self.update_state(state, resolve_id)
projectName: receive_card.project_name,
modelName: receive_card.model_name,
selectedVersionId: receive_card.selected_version_id,
selectedVersionSourceApp: receive_card.selected_version_source_app,
selectedVersionUserId: receive_card.selected_version_user_id,
latestVersionId: receive_card.latest_version_id,
latestVersionSourceApp: receive_card.latest_version_source_app,
latestVersionUserId: receive_card.latest_version_user_id,
hasDismissedUpdateWarning: receive_card.has_dismissed_update_warning,
expired: receive_card.expired,
bakedObjectIds: receive_card.baked_object_ids,
Expand Down
32 changes: 28 additions & 4 deletions speckle_connector_3/src/cards/receive_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@ class ReceiveCard < Card
# @return [String] selected version id to receive
attr_reader :selected_version_id

# @return [String] selected version source app
attr_reader :selected_version_source_app

# @return [String] selected version user id
attr_reader :selected_version_user_id

# @return [String] latest version id to receive
attr_reader :latest_version_id

# @return [String] latest version source app
attr_reader :latest_version_source_app

# @return [String] latest version user id
attr_reader :latest_version_user_id

# @return [Boolean] whether new version notification is dismissed or not
attr_reader :has_dismissed_update_warning

Expand All @@ -41,27 +53,39 @@ def initialize(
project_name,
model_name,
selected_version_id,
selected_version_source_app,
selected_version_user_id,
latest_version_id,
latest_version_source_app,
latest_version_user_id,
has_dismissed_update_warning,
expired,
baked_object_ids = nil
)
super(model_card_id, account_id, project_id, project_name, model_id, model_name)
@selected_version_id = selected_version_id
@selected_version_source_app = selected_version_source_app
@selected_version_user_id = selected_version_user_id
@latest_version_id = latest_version_id
@latest_version_source_app = latest_version_source_app
@latest_version_user_id = latest_version_user_id
@has_dismissed_update_warning = has_dismissed_update_warning
@baked_object_ids = baked_object_ids
@expired = expired
@model_name = model_name
@project_name = project_name
@type_discriminator = 'ReceiverModelCard'
self[:selected_version_id] = selected_version_id
self[:selected_version_source_app] = selected_version_source_app
self[:selected_version_user_id] = selected_version_user_id
self[:has_dismissed_update_warning] = has_dismissed_update_warning
self[:latest_version_id] = latest_version_id
self[:latest_version_source_app] = latest_version_source_app
self[:latest_version_user_id] = latest_version_user_id
self[:model_name] = model_name
self[:project_name] = project_name
self[:expired] = expired
self[:baked_object_ids] = @baked_object_ids
@expired = expired
@model_name = model_name
@project_name = project_name
@type_discriminator = 'ReceiverModelCard'
self[:type_discriminator] = @type_discriminator
end
# rubocop:enable Metrics/ParameterLists
Expand Down

0 comments on commit bc55543

Please sign in to comment.