Get model state and send filter for sketchup
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../action'
|
||||
|
||||
module SpeckleConnector
|
||||
module Actions
|
||||
# Gets model state.
|
||||
class GetModelState < Action
|
||||
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
|
||||
# @return [States::State] the new updated state object
|
||||
def self.update_state(state, resolve_id)
|
||||
model_state = {
|
||||
sendCards: [
|
||||
{
|
||||
projectId: 'Sketchup Project',
|
||||
modelId: 'Sketchup Model'
|
||||
},
|
||||
{
|
||||
projectId: 'Sketchup Project 2',
|
||||
modelId: 'Sketchup Model 2'
|
||||
}
|
||||
]
|
||||
}
|
||||
js_script = "baseBinding.receiveResponse('#{resolve_id}', #{model_state.to_json})"
|
||||
state.with_add_queue_js_command('getModelState', js_script)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,53 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../action'
|
||||
|
||||
module SpeckleConnector
|
||||
module Actions
|
||||
# Action to get send filter.
|
||||
class GetSendFilter < Action
|
||||
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
|
||||
# @return [States::State] the new updated state object
|
||||
def self.update_state(state, resolve_id)
|
||||
layer_tags = state.sketchup_state.sketchup_model.layers.collect do |layer|
|
||||
{
|
||||
id: layer.persistent_id,
|
||||
name: layer.display_name,
|
||||
active: true
|
||||
}
|
||||
end
|
||||
default_filters =
|
||||
{
|
||||
'everything': {
|
||||
name: 'Everything',
|
||||
input: 'toggle',
|
||||
duplicable: false,
|
||||
active: true
|
||||
},
|
||||
'selection': {
|
||||
name: 'Selection',
|
||||
input: 'toggle',
|
||||
duplicable: false,
|
||||
active: false
|
||||
},
|
||||
'tags': {
|
||||
name: 'Tags',
|
||||
input: 'toggle',
|
||||
active: false,
|
||||
duplicable: false,
|
||||
tags: layer_tags
|
||||
},
|
||||
'searchFilter': {
|
||||
name: 'Search',
|
||||
input: 'search',
|
||||
duplicable: true,
|
||||
active: false
|
||||
}
|
||||
}
|
||||
|
||||
js_script = "baseBinding.receiveResponse('#{resolve_id}', #{default_filters.to_json})"
|
||||
state.with_add_queue_js_command('getSendFilter', js_script)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../action'
|
||||
|
||||
module SpeckleConnector
|
||||
module Actions
|
||||
# Action to update send filter.
|
||||
class UpdateSendFilter < Action
|
||||
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
|
||||
# @return [States::State] the new updated state object
|
||||
def self.update_state(state, resolve_id, project_id, model_id, filter_id, filter)
|
||||
puts "Project id: #{project_id}"
|
||||
puts "Model id: #{model_id}"
|
||||
puts "Filter id: #{filter_id}"
|
||||
puts "Filter: #{filter}"
|
||||
js_script = "baseBinding.receiveResponse('#{resolve_id}')"
|
||||
state.with_add_queue_js_command('updateSendFilter', js_script)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -7,6 +7,9 @@ require_relative '../constants/path_constants'
|
||||
require_relative '../actions/get_accounts'
|
||||
require_relative '../actions/get_source_app_name'
|
||||
require_relative '../actions/get_document_info'
|
||||
require_relative '../actions/base_actions/get_send_filter'
|
||||
require_relative '../actions/base_actions/update_send_filter'
|
||||
require_relative '../actions/base_actions/get_model_state'
|
||||
|
||||
module SpeckleConnector
|
||||
module Ui
|
||||
@@ -18,7 +21,10 @@ module SpeckleConnector
|
||||
@commands ||= {
|
||||
getAccounts: Commands::ActionCommand.new(@app, self, Actions::GetAccounts),
|
||||
getSourceApplicationName: Commands::ActionCommand.new(@app, self, Actions::GetSourceAppName),
|
||||
getDocumentInfo: Commands::ActionCommand.new(@app, self, Actions::GetDocumentInfo)
|
||||
getDocumentInfo: Commands::ActionCommand.new(@app, self, Actions::GetDocumentInfo),
|
||||
getSendFilter: Commands::ActionCommand.new(@app, self, Actions::GetSendFilter),
|
||||
updateSendFilter: Commands::ActionCommand.new(@app, self, Actions::UpdateSendFilter),
|
||||
getModelState: Commands::ActionCommand.new(@app, self, Actions::GetModelState)
|
||||
}.freeze
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user