Skip to content

画面を1枚定義する

どの画面にも要る4つのキーと、レコードを1件に絞る key。

どの画面も、まず「どの種別か」「どのデータを扱うか」を書く。ここが決まれば、あとはその種別が持てるものを足していくだけになる。

yaml
dsl_version: "1.0"

page:
  type: master          # 画面の種別
  id: dept_master       # 画面の識別子(遷移先の指定に使う)
  title: 部門マスタ      # 画面に出る名前
  repository: deptRepository   # データの出し入れ先の名前
  key: code             # 1件を特定する項目

repository は「名前」であって実装ではない

repository に書くのは名前だけ。その名前で実際に何をするか(HTTP を叩く、DB を見る、メモリに持つ)は自分のコードで書いて、アプリ起動時に名前と結びつける。Framework は HTTP も DB も知らない。

key を書く画面と書かない画面

key は「この1件」を決めるための項目。詳細表示・編集・削除は、これが無いとどのレコードを触るのか決まらない。

逆に、1件を触らない画面(dashboard / report)には key を書かない。集計しか出さないので特定する対象が無い。

どの type を選ぶか

迷ったら、扱う対象が「一覧か1件か」「読むだけか書くか」で切る。

やりたいことtype
探して一覧に出して、その場で登録・修正・削除までcrud / master
探して一覧に出すだけ(照会)search
1件を読み取り専用で見せるdetail
1件を入力・編集する(一覧なし)form
長い入力を数ステップに分けるwizard
数字とグラフを並べるdashboard
印刷・PDF 向けに出すreport

判断に迷う場合の対照表は ページ種別の選び方 にある。

書けるキー

キー書く場所必須既定値有効なページ種別説明
typeactionstringcreate / edit / delete / navigate / plugin / export / print ほか)必須crud dashboard detail form master report search wizardAction type (open string). Built-ins: create, edit, delete, navigate, plugin, export, print.
typecolumnstringtext / number / badge / boolean / date / dateTime ほか)任意"text"crud dashboard detail form master report search wizardRender type (open string). Built-ins: text, number, badge, boolean, date, dateTime.
typecrudPagestringcrud必須crudPage kind.
typedashboardItemstringmetric / table / chart ほか)任意"metric"dashboardCard kind. Open string; built-ins below.
typedashboardPagestringdashboard必須dashboardPage kind.
typedetailPagestringdetail必須detailPage kind.
typefieldstringtext / textarea / number / select / multiSelect / checkbox / radio / date / dateTime / time / subTable ほか)任意"text"crud dashboard detail form master report search wizardField type (open string). Built-ins: text, textarea, number, select, multiSelect, checkbox, radio, date, dateTime, time, subTable. A subTable holds child rows — see columns / fields / source.
typefilterstringtext / textarea / number / select / multiSelect / checkbox / radio / date / dateTime / time ほか)任意"text"crud dashboard master report searchInput type (open string). Built-ins: text, textarea, number, select, multiSelect, checkbox, radio, date, dateTime, time.
typeformPagestringform必須formPage kind.
typemasterPagestringmaster必須masterPage kind.
typereportPagestringreport必須reportPage kind.
typesearchPagestringsearch必須searchPage kind.
typevalidatorstringrequired / maxLength / minLength / pattern / min / max / email / postalCode / compare ほか)必須crud dashboard detail form master report search wizardValidator type (open string). Built-ins: required, maxLength, minLength, pattern, min, max, email, postalCode, compare. compare is the cross-field one: it reads another field of the same record (see the node description for its parameters).
typewizardPagestringwizard必須wizardPage kind.
idactionstring必須crud dashboard detail form master report search wizard
idappstring必須すべて
idcrudPagestring必須crudStable page identifier.
iddashboardItemstring必須dashboardCard identifier.
iddashboardPagestring必須dashboard
iddetailPagestring必須detail
idformPagestring必須form
idmasterPagestring必須master
idmenuItemstring任意すべてRoute key for a leaf (defaults to page).
idreportPagestring必須report
idsearchPagestring必須search
idwizardPagestring必須wizard
idwizardStepstring必須wizardStep identifier.
titleactionPromptstring任意crud dashboard detail form master report search wizardDialog heading. Defaults to the action's label.
titleappstring必須すべて
titleconfirmstring任意crud dashboard detail form master report search wizardDialog heading. Omit for the renderer's default. May carry {count}.
titlecrudPagestring必須crudPage title.
titledashboardItemstring必須dashboardCard heading.
titledashboardPagestring必須dashboard
titledetailPagestring必須detail
titleformPagestring必須form
titlemasterPagestring必須master
titlereportPagestring必須report
titlesearchPagestring必須search
titlesectionstring任意crud detail form master
titlewizardPagestring必須wizard
titlewizardStepstring必須wizardStep heading.
repositorycrudPagestring必須crudKey resolving the user-provided Repository implementation.
repositorydashboardItemstring任意dashboardRepository key. Falls back to the page's.
repositorydashboardPagestring任意dashboardDefault repository key for cards that omit one.
repositorydetailPagestring必須detail
repositoryformPagestring必須form
repositorymasterPagestring必須master
repositoryoptionsSourcestring必須crud dashboard detail form master report search wizardRepository key holding the choices.
repositoryreportPagestring必須report
repositorysearchPagestring必須search
repositorysubTableSourcestring必須crud dashboard detail form master report search wizardRepository key for the child rows.
repositorywizardPagestring必須wizard
keycrudPagestring任意"id"crudPrimary-key field name of a record.
keydetailPagestring任意"id"detail
keyformPagestring任意"id"form
keymasterPagestring任意"id"master
keysearchPagestring任意"id"search
keysubTableSourcestring任意"id"crud dashboard detail form master report search wizardPrimary-key field of a child row, used to update/delete it.
keywizardPagestring任意"id"wizard

この表は spec/reference.json から生成している(JSON Schema が正)。手元では npx hatake reference <キー名> で同じものが引ける。

近い例

例は丸ごと写して直すのが一番速い。以下は CI で検証済み(そのまま動く形)。

ファイル種別画面どういうときに使うか
customer_detail.yamldetail顧客詳細1件の内容を読み取り専用で表示したい(一覧から開く先)

よくある間違い

dashboard / reportkey を書く

なぜ駄目か key は「1件のレコードの主キー項目名」。ダッシュボードと帳票は単一レコードを指さないので持たない。

こう直す 消す。行から1件を開きたいなら navigate アクションで detail ページへ渡す(params: { id: "$row.id" })。

yaml
page:
  type: report
  id: sales_report
  title: 売上明細表
  repository: orderRepository
  key: id
  table:
    columns:
      - { field: amount, label: 金額, type: number }
yaml
page:
  type: report
  id: sales_report
  title: 売上明細表
  repository: orderRepository
  table:
    columns:
      - { field: amount, label: 金額, type: number }

spec/pitfalls.json から生成。各項目は CI で検証済み(間違いは本当に落ち、正しい方は本当に通る)。手元では npx hatake pitfalls <キー名>

実物を見る

デモアプリの「顧客マスタ」がこれを使っている。 デモを開く