Module: UU::OS::VUC::ActionHelper

Defined in:
uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action_helper.rb

Overview

Class is used for building action uri which cause user navigation, opens dialog or trigger file download. Action can be:

* back - Returns to previous Use case, actual use case is finished
* super uc - Execute super Use case instead of this one and this one is finished
* forward - Navigate to another Use case, actual use case is finished
* dialog - Open modal dialog, actual use case is not finished but only suspended
* progress dialog - Open progress dialog, , actual use case is not finished but only suspended
* download - Creates action for launching download from client (browser)

Examples:

def on_init(ctx)

  view = ctx.view
  button = view.component(:BUTTON)

  button.action_uri = UU::OS::VUC::ActionHelper.create_dialog_uri(
      ctx,
      'ues:TER:DIALOG?VUC',
      :width => 400,
      :uuCallback => 'dialogClosed')
  return view
end

Constant Summary

Class Method Summary (collapse)

Class Method Details

+ (UU::OS::UESURI) create_back_uri(ctx, params = {})

Returns back action uri, user is navigated to previous use case. Actual use case is finished.

Examples:


# get button component
view = ctx.view
button = view.component(:BUTTON)

# back action
button.action_uri = UU::OS::VUC::ActionHelper.create_back_uri(ctx)

# same as previous, but info message is included, in this example 'Info message.' text is displayed
# at previous use case.
info_msg = UU::OS::GVC::Message.new(
{
     code: "CODE",
     severity: UU::OS::GVC::Message::MessageSeverity::INFO,
     text: "Info message."
})
button.action_uri = UU::OS::VUC::ActionHelper.create_back_uri(ctx, :uuMessages => [info_msg])

# include result to back action
button.action_uri = UU::OS::VUC::ActionHelper.create_back_uri(ctx, :uuResult => 'Some result')

# combination of result and messages
button.action_uri = UU::OS::VUC::ActionHelper.create_back_uri(ctx, :uuMessages => [info_msg], :uuResult => 'Some result')

Parameters:

Options Hash (params):

  • :uuMessages (Array)

    Array of GVC::Message objects used as message to user.

  • :uuResult (Object)

    Result can be small arbitrary object serializable to JSON.

Returns:



84
85
86
87
88
89
90
91
92
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action_helper.rb', line 84

def self.create_back_uri(ctx, params = {})
  uri_builder = UU::OS::UESURIBuilder.parse_uesuri(ctx.uu_uri)

  add_messages(uri_builder, params)
  add_result(uri_builder, params)
  uri_builder.set_action(BACK_ACTION_NAME)

  return uri_builder.to_uesuri
end

+ (UU::OS::UESURI) create_dialog_uri(ctx, uu_uri, params = {})

Returns uri which opens use case in modal window. Actual use case is not finished but only suspended.

Examples:


# get button component
view = ctx.view
button = view.component(:BUTTON)

# opens use case in modal window
button.action_uri = UU::OS::VUC::ActionHelper.create_dialog_uri(ctx, 'ues:TER:DIALOG?VUC&name=Thor')

# opens dialog with specified width and height
button.action_uri = UU::OS::VUC::ActionHelper.create_dialog_uri(ctx, 'ues:TER:DIALOG?VUC', :width => 400, :height => 300)

# opens dialog with callback action dialogClosed, it means that on_dialog_closed method will be called when
# dialog is closed
button.action_uri = UU::OS::VUC::ActionHelper.create_dialog_uri(ctx, 'ues:TER:DIALOG?VUC', :width => 400, :height => 300, :uuCallback => 'dialogClosed')

Parameters:

Options Hash (params):

  • :width (Integer)

    Dialog width

  • :height (Integer)

    Dialog height

  • :uuCallback (String)

    Callback action.

Returns:



200
201
202
203
204
205
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action_helper.rb', line 200

def self.create_dialog_uri(ctx, uu_uri, params = {})
  uri_builder = UU::OS::UESURIBuilder.parse_uesuri(uu_uri)
  add_target(uri_builder, TARGET_TYPE_DIALOG, params)
  add_callback(uri_builder, params)
  return uri_builder.to_uesuri
end

+ (UU::OS::UESURI) create_download_uri(ctx, uu_uri, params = {})

Returns uri which cause file download from client (browser).

Examples:


# get button component
view = ctx.view
button = view.component(:BUTTON)

#download attachment
button.action_uri = UU::OS::VUC::ActionHelper.create_download_uri(ctx, 'ues:TER:ART:ATTACHMENT')

# download attachment with callback action downloadCallback, it means that on_download_callback method will be called
button.action_uri = UU::OS::VUC::ActionHelper.create_download_uri(ctx, 'ues:TER:ART:ATTACHMENT', :uuCallbaqck => 'downloadCallback')

Parameters:

Returns:



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action_helper.rb', line 258

def self.create_download_uri(ctx, uu_uri, params = {})
  if uu_uri.nil? || (uu_uri.kind_of?(String) && uu_uri.empty?)
    return uu_uri
  end
  unless (uu_uri.kind_of?(String) && (uu_uri.start_with?('ues:') || uu_uri.start_with?('uu-uds:'))) || uu_uri.kind_of?(UU::OS::UESURI)
    raise ArgumentError.new("download_uri must be UES-URI instance or URI string containing UES-URI or UDS-URI, but it was #{uu_uri}.")
  end

  uri = UU::OS::UESURI.new(uu_uri)
  uri_builder = UU::OS::UESURIBuilder.parse_uesuri(uri)
  add_target(uri_builder, TARGET_TYPE_DOWNLOAD, params)
  add_callback(uri_builder, params)
  # TODO this fix is because UESURIBuilder do not support different scheme than 'ues' and we
  # expect e.g. 'uu-uds'
  str_uri = uri.schema + ':' + uri_builder.to_uesuri.to_s.gsub(/^ues:/, "")
  return UU::OS::UESURI.new(str_uri)
end

+ (UU::OS::UESURI) create_forward_uri(ctx, uu_uri, params = {})

Returns navigation uri to use case passed by 'uu_uri' parameter. Actual use case is finished.

Examples:


# get button component
view = ctx.view
button = view.component(:BUTTON)

#navigate to artifact's default action
button.action_uri = UU::OS::VUC::ActionHelper.create_forward_uri(ctx, 'ues:TER:ART')

# navigate to UC1
button.action_uri = UU::OS::VUC::ActionHelper.create_forward_uri(ctx, 'ues:TER:ART?UC1')

# navigate to UC1 with some params
button.action_uri = UU::OS::VUC::ActionHelper.create_forward_uri(ctx, 'ues:TER:ART?UC1&name=Thor&age=41')

# same as previous, but info message is included, in this example 'Info message.' text is displayed
# at next use case.
info_msg = UU::OS::GVC::Message.new(
 {
     code: "CODE",
     severity: UU::OS::GVC::Message::MessageSeverity::INFO,
     text: "Info message."
  })
button.action_uri = UU::OS::VUC::ActionHelper.create_forward_uri(ctx, 'ues:TER:ART?UC1&name=Thor&age=41', :uuMessages => [info_msg])

# same as previous, including result
button.action_uri = UU::OS::VUC::ActionHelper.create_forward_uri(ctx, 'ues:TER:ART?UC1&name=Thor&age=41', :uuResult => 'Some result')

# combination of result and messages
button.action_uri = UU::OS::VUC::ActionHelper.create_forward_uri(ctx, 'ues:TER:ART?UC1&name=Thor&age=41', :uuMessages => [info_msg], :uuResult => 'Some result')

Parameters:

Options Hash (params):

  • :uuMessages (Array)

Returns:



166
167
168
169
170
171
172
173
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action_helper.rb', line 166

def self.create_forward_uri(ctx, uu_uri, params = {})
  uri_builder = UU::OS::UESURIBuilder.parse_uesuri(uu_uri)

  add_messages(uri_builder, params)
  add_result(uri_builder, params)

  return uri_builder.to_uesuri
end

+ (UU::OS::UESURI) create_progress_dialog_uri(ctx, process_uri, params = {})

Returns uri that opens progress dialog that waits for specific process. Actual use case is not finished but only suspended.

Examples:


# get button component
view = ctx.view
button = view.component(:BUTTON)

# get process uri
process_uri = #...

# open progress dialog, that waits for specific process
UU::OS::VUC::ActionHelper.create_progress_dialog_uri(ctx, process_uri)

# open progress dialog, that waits for specific resultCode
UU::OS::VUC::ActionHelper.create_progress_dialog_uri(ctx, process_uri, :resultCode => 'ARTIFACT_CREATED')

# open progress dialog with callback action progressDialogClosed, it means that on_progress_dialog_closed method will be called
# when dialog is closed
UU::OS::VUC::ActionHelper.create_progress_dialog_uri(ctx, process_uri, :resultCode => 'ARTIFACT_CREATED', :uuCallback => 'progressDialogClosed')

Parameters:

Options Hash (params):

  • :resultCode (Integer)

    Code of process event providing result.

  • :uuCallback (String)

    Callback action.

Returns:



234
235
236
237
238
239
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action_helper.rb', line 234

def self.create_progress_dialog_uri(ctx, process_uri, params = {})
  uri_builder = UU::OS::UESURIBuilder.parse_uesuri(process_uri)
  add_target(uri_builder, TARGET_TYPE_PROGRESS_DIALOG, params)
  add_callback(uri_builder, params)
  return uri_builder.to_uesuri
end

+ (UU::OS::UESURI) create_super_uc_uri(ctx, params = {})

Returns super use case uri, user is navigated to the super use case implementation. Actual use case is finished.

Examples:


# get button component
view = ctx.view
button = view.component(:BUTTON)

# cause super uc action
button.action_uri = UU::OS::VUC::ActionHelper.create_super_uc_uri(ctx)

# same as previous, but info message is included, in this example 'Info message.' text is displayed
# at super use case.
info_msg = UU::OS::GVC::Message.new(
{
     code: "CODE",
     severity: UU::OS::GVC::Message::MessageSeverity::INFO,
     text: "Info message."
})
button.action_uri = UU::OS::VUC::ActionHelper.create_super_uc_uri(ctx, :uuMessages => [info_msg])

Parameters:

Options Hash (params):

  • :uuMessages (Array)

Returns:



119
120
121
122
123
124
125
126
# File 'uu_os_vuc-server-3.6.2/lib/uu/os/vuc/action_helper.rb', line 119

def self.create_super_uc_uri(ctx, params = {})
  uri_builder = UU::OS::UESURIBuilder.parse_uesuri(ctx.uu_uri)

  add_messages(uri_builder, params)
  uri_builder.set_action(SUPER_UC_ACTION_NAME)

  return uri_builder.to_uesuri
end