logologo
スタート
マニュアル
開発
プラグイン
API
ホーム
English
简体中文
日本語
한국어
Español
Português
Deutsch
Français
Русский
スタート
マニュアル
開発
プラグイン
API
ホーム
logologo
RunJS 概要
モジュールのインポート
コンテナ内でのレンダリング

グローバル変数

window
document
navigator

ctx

ctx.blockModel
ctx.collection
ctx.collectionField
ctx.dataSource
ctx.dataSourceManager
ctx.element
ctx.exit()
ctx.exitAll()
ctx.filterManager
ctx.form
ctx.getModel()
ctx.getValue()
ctx.getVar()
ctx.i18n
ctx.importAsync()
ctx.initResource()
ctx.libs
ctx.location
ctx.logger
ctx.makeResource()
ctx.message
ctx.modal
ctx.model
ctx.notification
ctx.off()
ctx.on()
ctx.openView()
ctx.render()
ctx.request()
ctx.requireAsync()
ctx.resource
ctx.route
ctx.router
ctx.setValue()
ctx.sql
ctx.t()
ctx.view
Previous Pagectx.on()
Next Pagectx.render()
AI翻訳通知

このドキュメントはAIによって翻訳されました。正確な情報については英語版をご参照ください。

#ctx.openView()

プログラムによって指定されたビュー(ドロワー、ポップアップ、埋め込みページなど)を開きます。FlowModelContext から提供され、JSBlock、テーブルセル、イベントフローなどのシナリオで、設定済みの ChildPage または PopupAction ビューを開くために使用されます。

#適用シナリオ

シナリオ説明
JSBlockボタンクリック後に詳細/編集ポップアップを開き、現在の行の filterByTk を渡します。
テーブルセルセル内にボタンをレンダリングし、クリック時に行の詳細ポップアップを開きます。
イベントフロー / JSAction操作成功後に次のビューまたはポップアップを開きます。
関連フィールドctx.runAction('openView', params) を介して選択/編集ポップアップを開きます。

注意:ctx.openView は FlowModel コンテキストが存在する RunJS 環境で利用可能です。uid に対応するモデルが存在しない場合、PopupActionModel が自動的に作成され、永続化されます。

#シグネチャ

openView(uid: string, options?: OpenViewOptions): Promise<void>

#パラメータ説明

#uid

ビューモデルの一意識別子。存在しない場合は自動的に作成・保存されます。同じポップアップを複数回開く際に設定を再利用できるよう、${ctx.model.uid}-detail のような安定した UID を使用することをお勧めします。

#options の主なフィールド

フィールド型説明
modedrawer / dialog / embed開き方:ドロワー(drawer)、ポップアップ(dialog)、埋め込み(embed)。デフォルトは drawer
sizesmall / medium / largeポップアップ/ドロワーのサイズ。デフォルトは medium
titlestringビューのタイトル
paramsRecord<string, any>ビューに渡される任意のパラメータ
filterByTkany主キー値。単一レコードの詳細/編集シナリオで使用されます
sourceIdstringソースレコード ID。関連シナリオで使用されます
dataSourceKeystringデータソース
collectionNamestringコレクション名
associationNamestring関連フィールド名
navigationbooleanルートナビゲーションを使用するかどうか。defineProperties または defineMethods が渡された場合、強制的に false に設定されます
preventCloseboolean閉じるのを阻止するかどうか
definePropertiesRecord<string, PropertyOptions>ビュー内のモデルにプロパティを動的に注入します
defineMethodsRecord<string, Function>ビュー内のモデルにメソッドを動的に注入します

#例文

#基本的な使い方:ドロワーを開く

const popupUid = `${ctx.model.uid}-detail`;
await ctx.openView(popupUid, {
  mode: 'drawer',
  size: 'medium',
  title: ctx.t('詳細'),
});

#現在の行のコンテキストを渡す

const primaryKey = ctx.collection?.primaryKey || 'id';
await ctx.openView(`${ctx.model.uid}-1`, {
  mode: 'dialog',
  title: ctx.t('行の詳細'),
  params: {
    filterByTk: ctx.record?.[primaryKey],
    record: ctx.record,
  },
});

#runAction を介して開く

モデルに openView アクション(関連フィールドやクリック可能なフィールドなど)が設定されている場合、以下のように呼び出すことができます:

await ctx.runAction('openView', {
  navigation: false,
  mode: 'dialog',
  collectionName: 'users',
  filterByTk: ctx.record?.id,
});

#カスタムコンテキストの注入

await ctx.openView(`${ctx.model.uid}-edit`, {
  mode: 'drawer',
  filterByTk: ctx.record?.id,
  defineProperties: {
    onSaved: {
      get: () => () => ctx.resource?.refresh?.(),
      cache: false,
    },
  },
});

#ctx.viewer、ctx.view との関係

用途推奨される使い方
設定済みのフロービューを開くctx.openView(uid, options)
カスタムコンテンツを開く(フローなし)ctx.viewer.dialog() / ctx.viewer.drawer()
現在開いているビューを操作するctx.view.close()、ctx.view.inputArgs

ctx.openView は FlowPage (ChildPageModel) を開き、内部で完全なフローページをレンダリングします。一方、ctx.viewer は任意の React コンテンツを開きます。

#注意事項

  • uid は複数のブロック間での衝突を避けるため、ctx.model.uid と関連付ける(例:${ctx.model.uid}-xxx)ことをお勧めします。
  • defineProperties または defineMethods を渡すと、リフレッシュ後のコンテキスト消失を防ぐため、navigation は強制的に false に設定されます。
  • ポップアップ内の ctx.view は現在のビューインスタンスを指し、ctx.view.inputArgs で開始時に渡されたパラメータを読み取ることができます。

#関連情報

  • ctx.view:現在開いているビューインスタンス
  • ctx.model:現在のモデル。安定した popupUid を構築するために使用されます。