Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Sv translation
languageen


Info
When using BellaDati for building custom applications in the UI, forms are very important part for adding and editing content. In this example we will focus on IoT application for tracking assets. End users will be allowed to add new and edit existing assets via forms.

Adding new assets

First we need to create data set structure, we will store ID, Name, Type and Manufacture year, so we will create columns with the following codes:

  • L_ID (attribute)
  • L_NAME (attribute)
  • L_TYPE (attribute)
  • L_MANUFACTURE_YEAR (attribute)

Now open Data collecting forms for the same data set:

  1. Select the option New import form
  2. Use name Add asset
  3. Select the option Edit in the column Elements
  4. Now add the following elements:
    1. ID - select type Unique ID
    2. Name - select type Text field
    3. Type  - select type Select
    4. Manufacture year - select type Text field
  5. Now we need to map the elements to the data set columns. In order to do that, click the element and select the attribute column that the element will be linked to and press the button Back. Repeat the same for all the elements. In our case, the element name matches the name of the column so the final settings will be as follows:  Image Modified
  6. In the last step, we need to load the values for the column Type. Use the following steps to do that:
    1. Select the element Type
    2. Click the button Edit items formula
    3. Enter the following formula (this formula will load all member values of column L_TYPE_NAME from the data set with code ASSET_TYPE): 

      Code Block
      def cV = []
      
      cV=allValues('ASSET_TYPE','L_TYPE_NAME')
      return cV


    4. Select the option Refresh on data change in the element mapping
  7. As the last step, we will set up the action for closing the dialogue window when the values are entered in the report pop-up view. Click the form name and use the following code in the section After submit JavaScript: 

    Code Block
    window.parent.layoutReload(true) 
    
    window.setTimeout(function() {
      window.parent.Kaelyn.closeAll()
    },1000) 


  8. Now add the form as a report view, click the button API and copy the ID of the new view: Image Modified
  9. Now the data set is ready and can be added to the report action button (this report must be based on the data set with the newly created form). Create a new report, this report will be used to display the list of available assets. For adding new assets, the action button will be used, use the following settings:
    1. Button type: URL
    2. Link: viewreport:ID of the view that you've copied in the previous step
    3. Link target: Open in a popup
    4. Width x Height: define based on the size of your form (e.g. 450x200 for our case)
    5. Show buttons: enable (thus option will display the control buttons for the form out of the view)
  10. Once defined, our new form will open in a popup and can be used for adding new data


Image Modified

Editing existing assets

For editing the existing assets, there has to be created a new form, you can use the same settings as for adding assets and then make the following adjustments:

  1. Change type of the element ID to Hidden and define the following formula @L_ID
  2. In the import form detail select the value of the field Edit row attribute to ID
  3. When defining the form link, add the following code: ?vr:L_ID=@ASSET_ID where ASSET_ID is the code of variable in the report for editing the asset detail


Sv translation
languageja


Info

BellaDatiを使用してUIでカスタムアプリケーションを構築する場合、フォームがコンテンツの追加と編集のために非常に重要な部分となります。この例では、アセットを追跡するためのIoTアプリケーションに焦点を当てます。エンドユーザーは、フォームを使って新しいアセットを追加したり、既存のアセットを編集することが可能になります。

新しいアセットの追加

まず、データセット構造を作成する必要があります。ID、名前、タイプ、製造年を格納するので、以下のコードでカラムを作成します:

  • L_ID (attribute)
  • L_NAME (attribute)
  • L_TYPE (attribute)
  • L_MANUFACTURE_YEAR (attribute)

次に、同じデータセットの「データ収集フォーム」を開きます:

  1. オプション「 新しいインポートフォーム 」を選択します。
  2. 名前を「アセットの追加」とします。
  3. Elementsの欄で「編集」のオプションを選択します。
  4. ここで、以下の要素を追加します:
    1. ID - 型は「固有ID」を選択します
    2. Name - 型は「テキストフィールド」を選択します
    3. Type  - 型は「選択」を選択します
    4. Manufacture year - 型は「テキストフィールド」を選択します
  5. ここで、要素をデータセットのカラムに対応させる必要があります。これを行うには、要素をクリックし、その要素がリンクされる属性列を選択し、戻るボタンを押下します。すべての要素について、同じことを繰り返します。今回の場合、要素名と列の名前が一致しているので、最終的な設定は以下のようになります:
    1. Image Added
  6. 最後のステップでは、カラムTypeの値をロードする必要があります。そのためには、次のステップを使用します:
    1. 要素の種類を選択します
    2. 項目式の編集」をクリックします。
    3. 次の数式を入力します(この数式は、コード ASSET_TYPE を持つデータセットから列 L_TYPE_NAME のすべてのメンバ値をロードします)。

      Code Block
      def cV = []
      
      cV=allValues('ASSET_TYPE','L_TYPE_NAME')
      return cV


    4. 要素マッピングの「変更時にフォームを更新」オプションを有効にします
  7. 最後のステップとして、レポートポップアップビューに値が入力されたときに、ダイアログウィンドウを閉じるためのアクションを設定することにします。フォーム名をクリックし、「JavaScriptの入力後」のセクションで次のコードを使用してください。

    Code Block
    window.parent.layoutReload(true) 
    
    window.setTimeout(function() {
      window.parent.Kaelyn.closeAll()
    },1000) 


  8. ここで、フォームをレポートビューとして追加し、ボタンAPIをクリックし、新しいビューのIDをコピーしてください。
    1. Image Added
  9. これでデータセットの準備ができましたので、レポートアクションボタンに追加することができます(このレポートは、新しく作成したフォームのデータセットに基づくものでなければなりません)。新しいレポートを作成します。このレポートは、利用可能なアセットのリストを表示するために使用されます。新しいアセットの追加には、アクションボタンが使用されるので、以下の設定を使用します:
    1. ボタンタイプ: URL
    2. リンク: viewreport:前のステップでコピーしたビューのID
    3. リンク先: 「ポップアップで表示
    4. 横幅 x 縦幅: フォームのサイズに基づいて定義します (例: 450x200)
    5. ボタンを表示: 有効 (このオプションにより、フォームのコントロールボタンがビューの外側に表示されます)
  10. 定義すると、新しいフォームがポップアップで開き、新しいデータを追加するために使用することができます。


Image Added

既存アセットの編集

既存のアセットを編集するには、新しいフォームを作成する必要があります。アセットの追加と同じ設定を使用し、以下の調整を行います:

  1. 要素IDのタイプを「隠れた」に変更し、以下の数式を定義します @L_ID
  2. インポートフォームの詳細で、「行の属性の編集 」フィールドの値をIDにします。
  3. フォームのリンクを定義する際に、以下のコードを追加してください: ?vr:L_ID=@ASSET_ID (このASSET_IDはアセット詳細編集用レポートの変数コードです)