### adding_new_dialog.md

- Open console in browser cmd + opt + I

- dialog must be found in preference/auth/route.json

  - (e.g. delivery_and_invoicing)

- dialogname.pug is saved in ma/plugin/dialog-folder

  - now you can see page in browser address: http://localhost/ma/dialogname

- Button to dialog must be in some begin-screen

  - e.g. begin_customer8.pug:
    .col-sm-12
    ma-begin-button.begin_action(ng-click="clickBeginUrl('stock_post')", ng-disabled="false")
    i.fa.fa-bar-chart.ma-begin
    ma-translate(ng-model='hdr.stock_post.begin_name') Stock collect

- Labels are translated into ??? lang_fi_customer.json

- Tabs to table:
  - tablename.pug must start with:
    - e.g. ng-include(src="'form/local/query_tool_header.html'")
    - this refers to file, where tab-links are defined
  - all tabs have the same start ( ng-include(src="'.... )
  - tab-link file is named XXfirst_tablenameXX_header.pug
  - tab-link file is saved to same folder as tablename.pug

#### Query quide

- there are two folders where jsons are saved:

  - preference/form/local/dialogname (e.g. dialogname = timer)
    - this folder contains common jsons which are used in many json querys
    - e.g. column.json , which gives gridareas column labels
  - preference/query/dialogname
    - this folder contains jsons querys which are specific
      - e.g. delivery_and_invoicing/delivered_not_invoiced
        {
        "query": [["wos_work_phase_state", "in", ["KU", "AL"]], "and", ["wo_state", "in", ["KU", "AL"]], "and", ["wos_work_load_group_id", "=", "load_group"]],
        "order": ["wos_phase_critical_start_date", ">", "wos_phase_critical_start_time", ">", "wos_production_lot__work_ph", ">"]
        }
    - also query_init.json is in this folder

- first line must include init-call

  - e.g. form.form-horizontal(ng-init='ma.callServer($view, "query", {"name": "form/local/work-center/query_init.json"})')
  - init calls json which gives info where data to popup, grids and rec locates
  - query_init.json:
    {
    "grid": "form/local/work-center/grid.json",
    "arr": "form/local/work-center/work-arr.json",
    "rec":["form/local/work-center/rec.json"],
    "hdr":[]
    }

    - query_grid.json:
      {
      "grid": [
      {
      "name": "work",
      "query": "form/local/work-center/work_query.json",
      "column": "form/local/work-center/work_column.json"
      },
      {
      "name": "phase",
      "query": "form/local/work-center/phase_query.json",
      "column": "form/local/work-center/phase_column.json"
      }
      ]
      }
    - work_center_popup.json
      {
      "load_group": [
      {
      "show": "Sahat",
      "value": "SAH"
      },
      {
      "show": "Hitsaus",
      "value": "HIT"
      },
      {
      "show": "Taivutus",
      "value": "TAIV"
      },
      {
      "show": "Sinkitys",
      "value": "SINK"
      }
      ]
      }

      - work_center_rec.json
        {
        "load_group": "SAH"
        }

        - work_query.json:
          {
          "parameter":{
          "load_group": "rec.resource"
          },
          "query": [["wos_work_phase_state", "in", ["KU", "AL"]], "and", ["wo_state", "in", ["KU", "AL"]], "and", ["wos_work_load_group_id", "=", "load_group"]],
          "order": ["wos_phase_critical_start_date", ">", "wos_phase_critical_start_time", ">", "wos_production_lot__work_ph", ">"]
          }
        - work_column.json
          {
          "column": [
          {
          "field": "wos_work_load_group_id",
          "width": 40,
          "name": "Kuor.",
          "editable": true
          },
          }
