{
	"name": "form/nc/erp-sync/erp-sync.json",
	"layout": {
		"component": "nc-form",
		"attribute": {
			"id": "erp-sync"
		},
		"element": [
			{
				"component": "nc-popup",
				"attribute": {
					"flowing": "flowing",
					"hoverable": "hoverable",
					"position": "bottom left",
					"v-if": "false",
					"width": "96%"
				},
				"element": [
					{
						"component": "span",
						"attribute": {
							"id": "nc-grid-popup",
							"slot": "trigger",
							"style": "margin-top: 3em; margin-left: -1em;"
						}
					},
					{
						"component": "nc-popup-content",
						"element": [
							{
								"component": "nc-label",
								"text": "Rows {{ (selectedRowRecord && selectedRowRecord.order_id + ', ' + selectedRowRecord.company_id) || '' }}",
								"attribute": {
									"model": "hdr.erp_sync.rows"
								}
							},
							{
								"component": "nc-row",
								"element": [
									{
										"component": "nc-grid",
										"attribute": {
											"id": "row_area",
											":doesExternalFilterPass": "doesExternalFilterPass",
											":isExternalFilterPresent": "isExternalFilterPresent",
											"height": "11.5em",
											"model": "grid.row_area",
											"v-on:grid-row-clicked": "gridRowClicked",
											"v-on:grid-row-double-clicked": "gridRowDoubleClicked",
											"v-on:grid-sort-changed": "gridSortChanged"
										}
									}
								]
							}
						]
					}
				]
			},
			{
				"component": "nc-row",
				"element": [
					{
						"component": "nc-col",
						"attribute": {
							"width": "22em",
							"class": ["nc-margin-right-big"]
						},
						"element": [
							{
								"component": "nc-label-dropdown",
								"text": "Connection",
								"attribute": {
									"hdr": "hdr.erp_sync.connection",
									"model": "rec.connection",
									"v-on:change": "changeConnection('update-data')"
								}
							}
						]
					},
					{
						"component": "nc-col",
						"attribute": {
							"v-show": "rec.conn?.firm_id",
							"width": "22em",
							"class": ["nc-margin-right-big"]
						},
						"element": [
							{
								"component": "nc-label-dropdown",
								"text": "Firm",
								"attribute": {
									"hdr": "hdr.erp_sync.firm_id",
									"model": "rec.conn.firm_id",
									"v-on:change": "tabChanged()"
								}
							}
						]
					},
					{
						"component": "nc-col",
						"attribute": {
							"width": "auto",
							"class": ["nc-center-v", "nc-end-h"]
						},
						"element": [
							{
								"component": "nc-col",
								"attribute": {
									"width": "15em"
								},
								"element": [
									{
										"component": "nc-label-input",
										"text": "Date range",
										"attribute": {
											"hdr": "hdr.erp_sync.date_range",
											"label-style-": "width: 7em; text-align: right;",
											"model": "rec.start_date"
										}
									}
								]
							},
							{
								"component": "nc-col",
								"attribute": {
									"width": "1em",
									"class": ["nc-center-h"]
								},
								"element": [
									{
										"component": "span",
										"text": "-",
										"attribute": {
											"class": ["input-group-addon"]
										}
									}
								]
							},
							{
								"component": "nc-col",
								"attribute": {
									"width": "8em"
								},
								"element": [
									{
										"component": "nc-input",
										"text": "End date",
										"attribute": {
											"model": "rec.end_date"
										}
									}
								]
							}
						]
					},
					{
						"component": "nc-col",
						"attribute": {
							"class": ["nc-end-h"],
							"width": "10em"
						},
						"element": [
							{
								"component": "nc-button",
								"attribute": {
									"class": ["nc-button-wide"],
									"primary": "primary",
									"v-on:click": "loadRows('all')",
									"text": "Update",
									"model": "hdr.erp_sync.update",
									"icon": "sync"
								}
							}
						]
					}
				]
			},
			{
				"component": "nc-divider"
			},
			{
				"component": "nc-row",
				"element": [
					{
						"component": "nc-tab",
						"attribute": {
							"model": "rec.tab",
							"v-on:change": "tabChanged"
						}
					}
				]
			},
			{
				"component": "nc-row",
				"element": [
					{
						"component": "nc-col",
						"attribute": {
							"width": "1/5"
						},
						"element": [
							{
								"component": "nc-image",
								"attribute": {
									":src": "rec.logo_path_local",
									"class": ["erp-sync-logo"]
								}
							}
						]
					},
					{
						"component": "nc-col",
						"attribute": {
							"class": ["nc-space-evenly"],
							"width": "3/5"
						},
						"element": [
							{
								"component": "nc-checkbox",
								"text": "Show open",
								"attribute": {
									"v-if": "false",
									"hdr": "hdr.erp_sync.show_open",
									"model": "rec.show_open",
									"v-on:click": "showRows"
								}
							},
							{
								"component": "nc-checkbox",
								"text": "Show new",
								"attribute": {
									"hdr": "hdr.erp_sync.show_new",
									"model": "rec.show_new",
									"v-on:click": "showRows"
								}
							},
							{
								"component": "nc-checkbox",
								"text": "Show changed",
								"attribute": {
									"hdr": "hdr.erp_sync.show_changed",
									"model": "rec.show_changed",
									"v-on:click": "showRows"
								}
							},
							{
								"component": "nc-checkbox",
								"text": "Show equal",
								"attribute": {
									"hdr": "hdr.erp_sync.show_equal",
									"model": "rec.show_equal",
									"v-on:click": "showRows"
								}
							},
							{
								"component": "nc-checkbox",
								"text": "Preview",
								"attribute": {
									"v-if": "true",
									"hdr": "hdr.erp_sync.show_preview",
									"model": "rec.show_preview",
									"v-on:click": "showPreview"
								}
							}
						]
					},
					{
						"component": "nc-col",
						"attribute": {
							"class": ["nc-end-h"],
							"margin-top": "0.5em",
							"width": "auto"
						},
						"element": [
							{
								"component": "nc-button",
								"attribute": {
									"class": ["nc-button-wide"],
									"style": "margin-top: 1em;",
									"primary": "primary",
									"v-on:click": "loadRows('local')",
									"text": "Update",
									"model": "hdr.erp_sync.update",
									"icon": "sync"
								}
							}
						]
					},
					{
						"component": "nc-col",
						"attribute": {
							"class": ["nc-animate-width"],
							":width": "rec.show_preview ? '70%' : '100%'"
						},
						"element": [
							{
								"component": "nc-row",
								"attribute": { "class": ["nc-align-top"] },
								"element": [
									{
										"component": "nc-grid",
										"attribute": {
											"id": "local",
											":doesExternalFilterPass": "doesExternalFilterPass",
											":isExternalFilterPresent": "isExternalFilterPresent",
											"height": "25vh",
											":height": "showFileList() ? '25vh' : '36vh'",
											"model": "grid.local",
											"v-on:grid-row-clicked": "gridRowClicked",
											"v-on:grid-row-double-clicked": "gridRowDoubleClicked",
											"v-on:grid-sort-changed": "gridSortChanged"
										}
									}
								]
							},
							{
								"component": "nc-row",
								"attribute": {
									"class": ["nc-margin-top"]
								},
								"element": [
									{
										"component": "nc-col",
										"attribute": {
											"width": "auto"
										},
										"element": [
											{
												"component": "nc-image",
												"attribute": {
													":src": "rec.logo_path_external",
													"class": ["erp-sync-logo"]
												}
											}
										]
									},
									{
										"component": "nc-col",
										"attribute": {
											"class": ["nc-end-h"],
											"v-if": "rec.conn?.load_detail?.[rec.tab]",
											"width": "12em"
										},
										"element": [
											{
												"component": "nc-button",
												"attribute": {
													"class": ["nc-button-wide"],
													":disabled": "!buttonEnabled('load_detail', 'external')",
													"v-on:click": "loadDetail()",
													"icon": "download",
													"text": "Load detail",
													"model": "hdr.erp_sync.load_detail"
												}
											}
										]
									},
									{
										"component": "nc-col",
										"attribute": {
											"class": ["nc-end-h"],
											"width": "12em"
										},
										"element": [
											{
												"component": "nc-checkbox",
												"text": "Export also to file",
												"attribute": {
													"v-if": "showFileList('export')",
													"model": "rec.export_also_to_file"
												}
											}
										]
									},
									{
										"component": "nc-col",
										"attribute": {
											"class": ["nc-end-h"],
											"width": "26em"
										},
										"element": [
											{
												"component": "nc-button",
												"attribute": {
													"class": ["nc-button-wide"],
													":disabled": "!buttonEnabled('import', 'external')",
													"v-on:click": "saveRows('external', 'import')",
													"icon": "arrow-circle-up",
													"text": "Import",
													"model": "hdr.erp_sync.import"
												}
											},
											{
												"component": "nc-button",
												"attribute": {
													"class": ["nc-button-wide"],
													":disabled": "!buttonEnabled('export', 'local')",
													"v-on:click": "saveRows('local', 'export')",
													"icon": "arrow-circle-down",
													"text": "Export",
													"model": "hdr.erp_sync.export"
												}
											},
											{
												"component": "nc-button",
												"attribute": {
													"class": ["nc-button-wide"],
													"primary": "primary",
													"v-on:click": "loadRows('external')",
													"text": "Update",
													"model": "hdr.erp_sync.update",
													"icon": "sync"
												}
											}
										]
									}
								]
							},
							{
								"component": "nc-row",
								"attribute": { "class": ["nc-align-top"] },
								"element": [
									{
										"component": "nc-grid",
										"attribute": {
											"id": "external",
											"model": "grid.external",
											":doesExternalFilterPass": "doesExternalFilterPass",
											":isExternalFilterPresent": "isExternalFilterPresent",
											":height": "showFileList() ? 'calc(55vh - 23em)' : 'calc(65vh - 23em)'",
											"v-on:grid-row-clicked": "gridRowClicked",
											"v-on:grid-row-double-clicked": "gridRowDoubleClicked",
											"v-on:grid-sort-changed": "gridSortChanged"
										}
									}
								]
							},
							{
								"component": "nc-row",
								"attribute": { "v-if": "showFileList()", "class": ["nc-align-top"] },
								"element": [
									{
										"component": "nc-col",
										"attribute": {
											"v-if": "showFileList('import')",
											":width": "showFileList('both') ? 'auto' : '100%'"
										},
										"element": [
											{
												"component": "nc-row",
												"element": [
													{
														"component": "nc-col",
														"attribute": { "width": "10em" },
														"element": [
															{
																"component": "nc-header",
																"text": "Import",
																"attribute": {
																	"model": "hdr.erp_sync.file_list_import",
																	"size": "medium"
																}
															}
														]
													},
													{
														"component": "nc-col",
														"attribute": { "width": "15em" },
														"element": [
															{
																"component": "nc-label-dropdown",
																"text": "File status",
																"attribute": {
																	"hdr": "hdr.erp_sync.file_status",
																	"model": "rec.file_status",
																	"v-on:change": "setImportPath(true)"
																}
															}
														]
													},
													{
														"component": "nc-col",
														"attribute": { "width": "auto" },
														"element": [
															{
																"component": "nc-label-input",
																"text": "Import path",
																"attribute": {
																	"icon": "link",
																	"v-on:click": "openPath('import')",
																	"hdr": "hdr.erp_sync.import_path",
																	"readonly": "readonly",
																	"model": "rec.import_path"
																}
															}
														]
													},
													{
														"component": "nc-col",
														"attribute": { "width": "18em", "class": ["nc-end-h", "nc-margin-bottom"] },
														"element": [
															{
																"component": "nc-button",
																"attribute": {
																	"class": ["nc-button-wide"],
																	":disabled": "!buttonEnabled('import', 'file_list_import')",
																	"v-on:click": "saveRows('file_list_import', 'import')",
																	"icon": "arrow-circle-up",
																	"text": "Import file",
																	"model": "hdr.erp_sync.import_file"
																}
															},
															{
																"component": "nc-button",
																"attribute": {
																	"class": ["nc-button-wide"],
																	"primary": "primary",
																	"v-on:click": "loadRows('file_list_import')",
																	"text": "Update",
																	"model": "hdr.erp_sync.update",
																	"icon": "sync"
																}
															}
														]
													}
												]
											},
											{
												"component": "nc-row",
												"element": [
													{
														"component": "nc-grid",
														"attribute": {
															"id": "file_list_import",
															"model": "grid.file_list_import",
															"height": "16vh",
															":doesExternalFilterPass": "doesExternalFilterPass",
															":isExternalFilterPresent": "isExternalFilterPresent",
															"v-on:grid-row-clicked": "gridRowClicked",
															"v-on:grid-row-double-clicked": "gridRowDoubleClicked",
															"v-on:grid-sort-changed": "gridSortChanged"
														}
													}
												]
											}
										]
									},
									{
										"component": "nc-col",
										"attribute": {
											"v-if": "showFileList('export')",
											":width": "showFileList('both') ? '2/5' : '100%'"
										},
										"element": [
											{
												"component": "nc-row",
												"element": [
													{
														"component": "nc-col",
														"attribute": { "width": "10em" },
														"element": [
															{
																"component": "nc-header",
																"text": "Export",
																"attribute": {
																	"model": "hdr.erp_sync.file_list_export",
																	"size": "medium"
																}
															}
														]
													},
													{
														"component": "nc-col",
														"attribute": { "width": "auto" },
														"element": [
															{
																"component": "nc-label-input",
																"text": "Export path",
																"attribute": {
																	"icon": "link",
																	"v-on:click": "openPath('export')",
																	"hdr": "hdr.erp_sync.export_path",
																	"readonly": "readonly",
																	"model": "rec.export_path"
																}
															}
														]
													},
													{
														"component": "nc-col",
														"attribute": { "width": "18em", "class": ["nc-end-h", "nc-margin-bottom"] },
														"element": [
															{
																"component": "nc-button",
																"attribute": {
																	"class": ["nc-button-wide"],
																	":disabled": "!buttonEnabled('export', 'external')",
																	"v-on:click": "saveRows('external', 'export')",
																	"icon": "arrow-circle-down",
																	"text": "Export file",
																	"model": "hdr.erp_sync.export_file"
																}
															},
															{
																"component": "nc-button",
																"attribute": {
																	"class": ["nc-button-wide"],
																	"primary": "primary",
																	"v-on:click": "loadRows('file_list_export')",
																	"text": "Update",
																	"model": "hdr.erp_sync.update",
																	"icon": "sync"
																}
															}
														]
													}
												]
											},
											{
												"component": "nc-row",
												"element": [
													{
														"component": "nc-grid",
														"attribute": {
															"id": "file_list_export",
															"model": "grid.file_list_export",
															"height": "16vh",
															":doesExternalFilterPass": "doesExternalFilterPass",
															":isExternalFilterPresent": "isExternalFilterPresent",
															"v-on:grid-row-clicked": "gridRowClicked",
															"v-on:grid-row-double-clicked": "gridRowDoubleClicked",
															"v-on:grid-sort-changed": "gridSortChanged"
														}
													}
												]
											}
										]
									}
								]
							}
						]
					},
					{
						"component": "transition",
						"attribute": {
							"name": "nc-slide-right"
						},
						"element": [
							{
								"component": "nc-col",
								"attribute": {
									"v-if": "rec.show_preview",
									"class": ["nc-align-top", "nc-align-top"],
									"width": "calc(30% - 1em)",
									"style": "margin-left: 1em"
								},
								"element": [
									{
										"component": "nc-row",
										"element": [
											{
												"component": "nc-col",
												"attribute": {
													"width": "2.5em"
												},
												"element": [
													{
														"component": "nc-button",
														"attribute": {
															"class": ["tiny", "basic", "icon"],
															"icon-style": "margin-left: 2px; color: green;",
															"icon": "download",
															"v-if": "rec.show_preview ",
															":disabled": "!rec.preview_content",
															"v-on:click": "downloadPreview"
														}
													}
												]
											},
											{
												"component": "nc-col",
												"attribute": {
													"width": "auto"
												},
												"element": [
													{
														"component": "nc-label",
														"text": "Preview",
														"attribute": {
															"model": "hdr.erp_sync.preview",
															"v-if": "rec.show_preview"
														}
													}
												]
											}
										]
									},
									{
										"component": "nc-row",
										"element": [
											{
												"component": "nc-row",
												"attribute": {
													"v-if": "rec.preview_type === 'code'",
													"style": "height: calc(100vh - 23em - 4px); width: 100%; border: 1px solid #ddd;"
												},
												"element": [
													{
														"component": "nc-code-editor",
														"attribute": {
															"id": "preview-editor",
															":code": "rec.preview_content",
															":language": "rec.preview_language",
															":line-numbers": "true"
														}
													}
												]
											},
											{
												"component": "nc-row",
												"attribute": {
													"v-if": "rec.preview_type === 'html'",
													"style": "height: calc(100vh - 23em - 4px); width: 100%; border: 1px solid #ddd; overflow: auto;"
												},
												"element": [
													{
														"component": "div",
														"attribute": {
															"v-html": "rec.preview_content"
														}
													}
												]
											},
											{
												"component": "nc-row",
												"attribute": {
													"v-if": "!rec.preview_type",
													"style": "height: calc(100vh - 23em - 4px); width: 100%; display: flex; align-items: center; justify-content: center; color: #999;"
												},
												"element": [
													{
														"component": "nc-translate",
														"text": "Drop file here to preview (XML, JSON, JS, Lua, CSS, HTML, MD, TXT)",
														"attribute": {
															"model": "hdr.erp_sync.drop_hint"
														}
													},
													{
														"component": "nc-droparea",
														"attribute": {
															":clickable": "true",
															"v-on:import-file": "importFile"
														}
													}
												]
											}
										]
									}
								]
							}
						]
					}
				]
			}
		]
	}
}
