module_settings.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. package modules
  2. import (
  3. "html"
  4. "io/ioutil"
  5. "os"
  6. "golang-fave/engine/assets"
  7. "golang-fave/engine/builder"
  8. "golang-fave/engine/consts"
  9. "golang-fave/engine/utils"
  10. "golang-fave/engine/wrapper"
  11. )
  12. func (this *Modules) RegisterModule_Settings() *Module {
  13. return this.newModule(MInfo{
  14. Mount: "settings",
  15. Name: "Settings",
  16. Order: 801,
  17. System: true,
  18. Icon: assets.SysSvgIconGear,
  19. Sub: &[]MISub{
  20. {Mount: "default", Name: "General", Show: true, Icon: assets.SysSvgIconGear},
  21. {Mount: "robots-txt", Name: "Robots.txt", Show: true, Icon: assets.SysSvgIconBug},
  22. {Mount: "pagination", Name: "Pagination", Show: true, Icon: assets.SysSvgIconPagination},
  23. {Mount: "thumbnails", Name: "Thumbnails", Show: true, Icon: assets.SysSvgIconThumbnails},
  24. {Mount: "domains", Name: "Domains", Show: true, Icon: assets.SysSvgIconApi},
  25. {Mount: "smtp", Name: "SMTP", Show: true, Icon: assets.SysSvgIconEmail},
  26. {Mount: "shop", Name: "Shop", Show: true, Icon: assets.SysSvgIconShop},
  27. {Mount: "api", Name: "API", Show: true, Icon: assets.SysSvgIconApi},
  28. },
  29. }, nil, func(wrap *wrapper.Wrapper) (string, string, string) {
  30. content := ""
  31. sidebar := ""
  32. if wrap.CurrSubModule == "" || wrap.CurrSubModule == "default" {
  33. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  34. {Name: "General"},
  35. })
  36. content += builder.DataForm(wrap, []builder.DataFormField{
  37. {
  38. Kind: builder.DFKHidden,
  39. Name: "action",
  40. Value: "settings-general",
  41. },
  42. {
  43. Kind: builder.DFKText,
  44. CallBack: func(field *builder.DataFormField) string {
  45. modules_list := ``
  46. modules_list += `<select class="form-control" id="lbl_module-at-home" name="module-at-home">`
  47. modules_list += `<option value="0"`
  48. if (*wrap.Config).Engine.MainModule == 0 {
  49. modules_list += ` selected`
  50. }
  51. modules_list += `>Pages</option>`
  52. modules_list += `<option value="1"`
  53. if (*wrap.Config).Engine.MainModule == 1 {
  54. modules_list += ` selected`
  55. }
  56. modules_list += `>Blog</option>`
  57. modules_list += `<option value="2"`
  58. if (*wrap.Config).Engine.MainModule == 2 {
  59. modules_list += ` selected`
  60. }
  61. modules_list += `>Shop</option>`
  62. modules_list += `</select>`
  63. return `<div class="form-group n3">` +
  64. `<div class="row">` +
  65. `<div class="col-md-3">` +
  66. `<label for="lbl_module-at-home">Module at home page</label>` +
  67. `</div>` +
  68. `<div class="col-md-9">` +
  69. `<div>` +
  70. modules_list +
  71. `</div>` +
  72. `</div>` +
  73. `</div>` +
  74. `</div>`
  75. },
  76. },
  77. {
  78. Kind: builder.DFKCheckBox,
  79. Caption: "Maintenance",
  80. Name: "maintenance",
  81. Value: utils.IntToStr((*wrap.Config).Engine.Maintenance),
  82. Hint: "Close web site for maintenance",
  83. },
  84. {
  85. Kind: builder.DFKCheckBox,
  86. Caption: "Blog is enabled",
  87. Name: "mod-enabled-blog",
  88. Value: utils.IntToStr((*wrap.Config).Modules.Enabled.Blog),
  89. Hint: "Module can be enabled or fully disabled",
  90. },
  91. {
  92. Kind: builder.DFKCheckBox,
  93. Caption: "Shop is enabled",
  94. Name: "mod-enabled-shop",
  95. Value: utils.IntToStr((*wrap.Config).Modules.Enabled.Shop),
  96. Hint: "Module can be enabled or fully disabled",
  97. },
  98. {
  99. Kind: builder.DFKSubmit,
  100. Value: "Save",
  101. Target: "add-edit-button",
  102. },
  103. })
  104. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  105. } else if wrap.CurrSubModule == "robots-txt" {
  106. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  107. {Name: "Robots.txt"},
  108. })
  109. fcont := []byte(``)
  110. fcont, _ = ioutil.ReadFile(wrap.DTemplate + string(os.PathSeparator) + "robots.txt")
  111. content += builder.DataForm(wrap, []builder.DataFormField{
  112. {
  113. Kind: builder.DFKHidden,
  114. Name: "action",
  115. Value: "settings-robots-txt",
  116. },
  117. {
  118. Kind: builder.DFKText,
  119. CallBack: func(field *builder.DataFormField) string {
  120. return `<div class="form-group last"><div class="row"><div class="col-12"><textarea class="form-control autosize" id="lbl_content" name="content" placeholder="" autocomplete="off">` + html.EscapeString(string(fcont)) + `</textarea></div></div></div>`
  121. },
  122. },
  123. {
  124. Kind: builder.DFKSubmit,
  125. CallBack: func(field *builder.DataFormField) string {
  126. return `<div class="row d-lg-none"><div class="col-12"><div class="pt-3"><button type="submit" class="btn btn-primary" data-target="add-edit-button">Save</button></div></div></div>`
  127. },
  128. },
  129. })
  130. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  131. } else if wrap.CurrSubModule == "pagination" {
  132. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  133. {Name: "Pagination"},
  134. })
  135. content += builder.DataForm(wrap, []builder.DataFormField{
  136. {
  137. Kind: builder.DFKHidden,
  138. Name: "action",
  139. Value: "settings-pagination",
  140. },
  141. {
  142. Kind: builder.DFKNumber,
  143. Caption: "Blog main page",
  144. Name: "blog-index",
  145. Min: "1",
  146. Max: "100",
  147. Required: true,
  148. Value: utils.IntToStr((*wrap.Config).Blog.Pagination.Index),
  149. },
  150. {
  151. Kind: builder.DFKNumber,
  152. Caption: "Blog category page",
  153. Name: "blog-category",
  154. Min: "1",
  155. Max: "100",
  156. Required: true,
  157. Value: utils.IntToStr((*wrap.Config).Blog.Pagination.Category),
  158. },
  159. {
  160. Kind: builder.DFKText,
  161. Caption: "",
  162. Name: "",
  163. Value: "",
  164. CallBack: func(field *builder.DataFormField) string {
  165. return `<hr>`
  166. },
  167. },
  168. {
  169. Kind: builder.DFKNumber,
  170. Caption: "Shop main page",
  171. Name: "shop-index",
  172. Min: "1",
  173. Max: "100",
  174. Required: true,
  175. Value: utils.IntToStr((*wrap.Config).Shop.Pagination.Index),
  176. },
  177. {
  178. Kind: builder.DFKNumber,
  179. Caption: "Shop category page",
  180. Name: "shop-category",
  181. Min: "1",
  182. Max: "100",
  183. Required: true,
  184. Value: utils.IntToStr((*wrap.Config).Shop.Pagination.Category),
  185. },
  186. {
  187. Kind: builder.DFKSubmit,
  188. Value: "Save",
  189. Target: "add-edit-button",
  190. },
  191. })
  192. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  193. } else if wrap.CurrSubModule == "thumbnails" {
  194. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  195. {Name: "Thumbnails"},
  196. })
  197. content += builder.DataForm(wrap, []builder.DataFormField{
  198. {
  199. Kind: builder.DFKHidden,
  200. Name: "action",
  201. Value: "settings-thumbnails",
  202. },
  203. {
  204. Kind: builder.DFKText,
  205. CallBack: func(field *builder.DataFormField) string {
  206. resize_list := ``
  207. resize_list += `<select class="form-control" name="shop-thumbnail-r-1">`
  208. resize_list += `<option value="0"`
  209. if (*wrap.Config).Shop.Thumbnails.Thumbnail1[2] == 0 {
  210. resize_list += ` selected`
  211. }
  212. resize_list += `>Crop</option>`
  213. resize_list += `<option value="1"`
  214. if (*wrap.Config).Shop.Thumbnails.Thumbnail1[2] == 1 {
  215. resize_list += ` selected`
  216. }
  217. resize_list += `>Resize</option>`
  218. resize_list += `<option value="2"`
  219. if (*wrap.Config).Shop.Thumbnails.Thumbnail1[2] == 2 {
  220. resize_list += ` selected`
  221. }
  222. resize_list += `>Fit into size</option>`
  223. resize_list += `</select>`
  224. return `<div class="form-group n3">` +
  225. `<div class="row">` +
  226. `<div class="col-md-3">` +
  227. `<label>Shop thumbnail 1</label>` +
  228. `</div>` +
  229. `<div class="col-md-9">` +
  230. `<div>` +
  231. `<div class="row">` +
  232. `<div class="col-md-3">` +
  233. `<div><input class="form-control" type="number" name="shop-thumbnail-w-1" value="` + utils.IntToStr((*wrap.Config).Shop.Thumbnails.Thumbnail1[0]) + `" min="100" max="1000" placeholder="" autocomplete="off" required></div>` +
  234. `<div class="d-md-none mb-3"></div>` +
  235. `</div>` +
  236. `<div class="col-md-3">` +
  237. `<div><input class="form-control" type="number" name="shop-thumbnail-h-1" value="` + utils.IntToStr((*wrap.Config).Shop.Thumbnails.Thumbnail1[1]) + `" min="100" max="1000" placeholder="" autocomplete="off" required></div>` +
  238. `<div class="d-md-none mb-3"></div>` +
  239. `</div>` +
  240. `<div class="col-md-6">` +
  241. resize_list +
  242. `</div>` +
  243. `</div>` +
  244. `</div>` +
  245. `</div>` +
  246. `</div>` +
  247. `</div>`
  248. },
  249. },
  250. {
  251. Kind: builder.DFKText,
  252. CallBack: func(field *builder.DataFormField) string {
  253. resize_list := ``
  254. resize_list += `<select class="form-control" name="shop-thumbnail-r-2">`
  255. resize_list += `<option value="0"`
  256. if (*wrap.Config).Shop.Thumbnails.Thumbnail2[2] == 0 {
  257. resize_list += ` selected`
  258. }
  259. resize_list += `>Crop</option>`
  260. resize_list += `<option value="1"`
  261. if (*wrap.Config).Shop.Thumbnails.Thumbnail2[2] == 1 {
  262. resize_list += ` selected`
  263. }
  264. resize_list += `>Resize</option>`
  265. resize_list += `<option value="2"`
  266. if (*wrap.Config).Shop.Thumbnails.Thumbnail2[2] == 2 {
  267. resize_list += ` selected`
  268. }
  269. resize_list += `>Fit into size</option>`
  270. resize_list += `</select>`
  271. return `<div class="form-group n3">` +
  272. `<div class="row">` +
  273. `<div class="col-md-3">` +
  274. `<label>Shop thumbnail 2</label>` +
  275. `</div>` +
  276. `<div class="col-md-9">` +
  277. `<div>` +
  278. `<div class="row">` +
  279. `<div class="col-md-3">` +
  280. `<div><input class="form-control" type="number" name="shop-thumbnail-w-2" value="` + utils.IntToStr((*wrap.Config).Shop.Thumbnails.Thumbnail2[0]) + `" min="100" max="1000" placeholder="" autocomplete="off" required></div>` +
  281. `<div class="d-md-none mb-3"></div>` +
  282. `</div>` +
  283. `<div class="col-md-3">` +
  284. `<div><input class="form-control" type="number" name="shop-thumbnail-h-2" value="` + utils.IntToStr((*wrap.Config).Shop.Thumbnails.Thumbnail2[1]) + `" min="100" max="1000" placeholder="" autocomplete="off" required></div>` +
  285. `<div class="d-md-none mb-3"></div>` +
  286. `</div>` +
  287. `<div class="col-md-6">` +
  288. resize_list +
  289. `</div>` +
  290. `</div>` +
  291. `</div>` +
  292. `</div>` +
  293. `</div>` +
  294. `</div>`
  295. },
  296. },
  297. {
  298. Kind: builder.DFKText,
  299. CallBack: func(field *builder.DataFormField) string {
  300. resize_list := ``
  301. resize_list += `<select class="form-control" name="shop-thumbnail-r-3">`
  302. resize_list += `<option value="0"`
  303. if (*wrap.Config).Shop.Thumbnails.Thumbnail3[2] == 0 {
  304. resize_list += ` selected`
  305. }
  306. resize_list += `>Crop</option>`
  307. resize_list += `<option value="1"`
  308. if (*wrap.Config).Shop.Thumbnails.Thumbnail3[2] == 1 {
  309. resize_list += ` selected`
  310. }
  311. resize_list += `>Resize</option>`
  312. resize_list += `<option value="2"`
  313. if (*wrap.Config).Shop.Thumbnails.Thumbnail3[2] == 2 {
  314. resize_list += ` selected`
  315. }
  316. resize_list += `>Fit into size</option>`
  317. resize_list += `</select>`
  318. return `<div class="form-group n3">` +
  319. `<div class="row">` +
  320. `<div class="col-md-3">` +
  321. `<label>Shop thumbnail 3</label>` +
  322. `</div>` +
  323. `<div class="col-md-9">` +
  324. `<div>` +
  325. `<div class="row">` +
  326. `<div class="col-md-3">` +
  327. `<div><input class="form-control" type="number" name="shop-thumbnail-w-3" value="` + utils.IntToStr((*wrap.Config).Shop.Thumbnails.Thumbnail3[0]) + `" min="100" max="1000" placeholder="" autocomplete="off" required></div>` +
  328. `<div class="d-md-none mb-3"></div>` +
  329. `</div>` +
  330. `<div class="col-md-3">` +
  331. `<div><input class="form-control" type="number" name="shop-thumbnail-h-3" value="` + utils.IntToStr((*wrap.Config).Shop.Thumbnails.Thumbnail3[1]) + `" min="100" max="1000" placeholder="" autocomplete="off" required></div>` +
  332. `<div class="d-md-none mb-3"></div>` +
  333. `</div>` +
  334. `<div class="col-md-6">` +
  335. resize_list +
  336. `</div>` +
  337. `</div>` +
  338. `</div>` +
  339. `</div>` +
  340. `</div>` +
  341. `</div>`
  342. },
  343. },
  344. {
  345. Kind: builder.DFKText,
  346. CallBack: func(field *builder.DataFormField) string {
  347. resize_list := ``
  348. resize_list += `<select class="form-control" name="shop-thumbnail-r-full">`
  349. resize_list += `<option value="0"`
  350. if (*wrap.Config).Shop.Thumbnails.ThumbnailFull[2] == 0 {
  351. resize_list += ` selected`
  352. }
  353. resize_list += `>Crop</option>`
  354. resize_list += `<option value="1"`
  355. if (*wrap.Config).Shop.Thumbnails.ThumbnailFull[2] == 1 {
  356. resize_list += ` selected`
  357. }
  358. resize_list += `>Resize</option>`
  359. resize_list += `<option value="2"`
  360. if (*wrap.Config).Shop.Thumbnails.ThumbnailFull[2] == 2 {
  361. resize_list += ` selected`
  362. }
  363. resize_list += `>Fit into size</option>`
  364. resize_list += `</select>`
  365. return `<div class="form-group n3">` +
  366. `<div class="row">` +
  367. `<div class="col-md-3">` +
  368. `<label>Shop thumbnail full</label>` +
  369. `</div>` +
  370. `<div class="col-md-9">` +
  371. `<div>` +
  372. `<div class="row">` +
  373. `<div class="col-md-3">` +
  374. `<div><input class="form-control" type="number" name="shop-thumbnail-w-full" value="` + utils.IntToStr((*wrap.Config).Shop.Thumbnails.ThumbnailFull[0]) + `" min="100" max="1000" placeholder="" autocomplete="off" required></div>` +
  375. `<div class="d-md-none mb-3"></div>` +
  376. `</div>` +
  377. `<div class="col-md-3">` +
  378. `<div><input class="form-control" type="number" name="shop-thumbnail-h-full" value="` + utils.IntToStr((*wrap.Config).Shop.Thumbnails.ThumbnailFull[1]) + `" min="100" max="1000" placeholder="" autocomplete="off" required></div>` +
  379. `<div class="d-md-none mb-3"></div>` +
  380. `</div>` +
  381. `<div class="col-md-6">` +
  382. resize_list +
  383. `</div>` +
  384. `</div>` +
  385. `</div>` +
  386. `</div>` +
  387. `</div>` +
  388. `</div>`
  389. },
  390. },
  391. {
  392. Kind: builder.DFKSubmit,
  393. Value: "Save",
  394. Target: "add-edit-button",
  395. },
  396. })
  397. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  398. } else if wrap.CurrSubModule == "domains" {
  399. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  400. {Name: "Domains"},
  401. })
  402. fcont := []byte(``)
  403. fcont, _ = ioutil.ReadFile(wrap.DConfig + string(os.PathSeparator) + ".domains")
  404. content += builder.DataForm(wrap, []builder.DataFormField{
  405. {
  406. Kind: builder.DFKHidden,
  407. Name: "action",
  408. Value: "settings-domains",
  409. },
  410. {
  411. Kind: builder.DFKText,
  412. CallBack: func(field *builder.DataFormField) string {
  413. return `<div class="form-group last"><div class="row"><div class="col-12"><textarea class="form-control autosize" id="lbl_content" name="content" placeholder="" autocomplete="off">` + html.EscapeString(string(fcont)) + `</textarea></div></div></div>`
  414. },
  415. },
  416. {
  417. Kind: builder.DFKSubmit,
  418. CallBack: func(field *builder.DataFormField) string {
  419. return `<div class="row d-lg-none"><div class="col-12"><div class="pt-3"><button type="submit" class="btn btn-primary" data-target="add-edit-button">Save</button></div></div></div>`
  420. },
  421. },
  422. })
  423. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  424. } else if wrap.CurrSubModule == "smtp" {
  425. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  426. {Name: "SMTP"},
  427. })
  428. content += builder.DataForm(wrap, []builder.DataFormField{
  429. {
  430. Kind: builder.DFKHidden,
  431. Name: "action",
  432. Value: "settings-smtp",
  433. },
  434. {
  435. Kind: builder.DFKText,
  436. Caption: "SMTP server host",
  437. Name: "smtp-host",
  438. Value: (*wrap.Config).SMTP.Host,
  439. Hint: "Example: smtp.gmail.com",
  440. },
  441. {
  442. Kind: builder.DFKNumber,
  443. Caption: "SMTP server port",
  444. Name: "smtp-port",
  445. Min: "0",
  446. Max: "9999",
  447. Required: true,
  448. Value: utils.IntToStr((*wrap.Config).SMTP.Port),
  449. Hint: "Example: 587",
  450. },
  451. {
  452. Kind: builder.DFKText,
  453. Caption: "SMTP user login",
  454. Name: "smtp-login",
  455. Value: (*wrap.Config).SMTP.Login,
  456. Hint: "Example: example@gmail.com",
  457. },
  458. {
  459. Kind: builder.DFKPassword,
  460. Caption: "SMTP user password",
  461. Name: "smtp-password",
  462. Value: "",
  463. Hint: "Leave this field empty if you don't want change password",
  464. },
  465. {
  466. Kind: builder.DFKText,
  467. Caption: "Email address for testing",
  468. Name: "smtp-test-email",
  469. Value: "",
  470. Hint: "To this email address will be send test email message if settings are correct",
  471. },
  472. {
  473. Kind: builder.DFKSubmit,
  474. Value: "Save",
  475. Target: "add-edit-button",
  476. },
  477. })
  478. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  479. } else if wrap.CurrSubModule == "shop" {
  480. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  481. {Name: "Shop"},
  482. })
  483. content += builder.DataForm(wrap, []builder.DataFormField{
  484. {
  485. Kind: builder.DFKHidden,
  486. Name: "action",
  487. Value: "settings-shop",
  488. },
  489. {
  490. Kind: builder.DFKText,
  491. CallBack: func(field *builder.DataFormField) string {
  492. price_format_list := ``
  493. price_format_list += `<select class="form-control" id="lbl_price-fomat" name="price-fomat">`
  494. price_format_list += `<option value="0"`
  495. if (*wrap.Config).Shop.Price.Format == 0 {
  496. price_format_list += ` selected`
  497. }
  498. price_format_list += `>100</option>`
  499. price_format_list += `<option value="1"`
  500. if (*wrap.Config).Shop.Price.Format == 1 {
  501. price_format_list += ` selected`
  502. }
  503. price_format_list += `>100.0</option>`
  504. price_format_list += `<option value="2"`
  505. if (*wrap.Config).Shop.Price.Format == 2 {
  506. price_format_list += ` selected`
  507. }
  508. price_format_list += `>100.00</option>`
  509. price_format_list += `<option value="3"`
  510. if (*wrap.Config).Shop.Price.Format == 3 {
  511. price_format_list += ` selected`
  512. }
  513. price_format_list += `>100.000</option>`
  514. price_format_list += `<option value="4"`
  515. if (*wrap.Config).Shop.Price.Format == 4 {
  516. price_format_list += ` selected`
  517. }
  518. price_format_list += `>100.0000</option>`
  519. price_format_list += `</select>`
  520. price_round_list := ``
  521. price_round_list += `<select class="form-control" id="lbl_price-round" name="price-round">`
  522. price_round_list += `<option value="0"`
  523. if (*wrap.Config).Shop.Price.Round == 0 {
  524. price_round_list += ` selected`
  525. }
  526. price_round_list += `>Don't round</option>`
  527. price_round_list += `<option value="1"`
  528. if (*wrap.Config).Shop.Price.Round == 1 {
  529. price_round_list += ` selected`
  530. }
  531. price_round_list += `>Round to ceil</option>`
  532. price_round_list += `<option value="2"`
  533. if (*wrap.Config).Shop.Price.Round == 2 {
  534. price_round_list += ` selected`
  535. }
  536. price_round_list += `>Round to floor</option>`
  537. price_round_list += `</select>`
  538. return `<div class="form-group n2">` +
  539. `<div class="row">` +
  540. `<div class="col-md-3">` +
  541. `<label for="lbl_price-fomat">Price format</label>` +
  542. `</div>` +
  543. `<div class="col-md-9">` +
  544. `<div>` +
  545. price_format_list +
  546. `</div>` +
  547. `</div>` +
  548. `</div>` +
  549. `</div>` +
  550. `<div class="form-group n3">` +
  551. `<div class="row">` +
  552. `<div class="col-md-3">` +
  553. `<label for="lbl_price-round">Price round</label>` +
  554. `</div>` +
  555. `<div class="col-md-9">` +
  556. `<div>` +
  557. price_round_list +
  558. `</div>` +
  559. `</div>` +
  560. `</div>` +
  561. `</div>`
  562. },
  563. },
  564. {
  565. Kind: builder.DFKText,
  566. CallBack: func(field *builder.DataFormField) string {
  567. make_checkbox := func(name, caption string, value int) string {
  568. checked := ""
  569. if value > 0 {
  570. checked = " checked"
  571. }
  572. return `<div class="checkbox-clickable"><input class="form-control" type="checkbox" id="lbl_` +
  573. name + `" name="` + name + `" value="1" "="" autocomplete="off"` + checked +
  574. `><label for="lbl_` + name + `">` + caption + `</label></div>`
  575. }
  576. checkboxes := ""
  577. checkboxes += make_checkbox("require-last-name", "Last Name", (*wrap.Config).Shop.Orders.RequiredFields.LastName)
  578. checkboxes += make_checkbox("require-first-name", "First Name", (*wrap.Config).Shop.Orders.RequiredFields.FirstName)
  579. checkboxes += make_checkbox("require-middle-name", "Middle Name", (*wrap.Config).Shop.Orders.RequiredFields.MiddleName)
  580. checkboxes += make_checkbox("require-mobile-phone", "Mobile Phone", (*wrap.Config).Shop.Orders.RequiredFields.MobilePhone)
  581. checkboxes += make_checkbox("require-email-address", "Email Address", (*wrap.Config).Shop.Orders.RequiredFields.EmailAddress)
  582. checkboxes += make_checkbox("require-delivery", "Delivery", (*wrap.Config).Shop.Orders.RequiredFields.Delivery)
  583. checkboxes += make_checkbox("require-comment", "Comment", (*wrap.Config).Shop.Orders.RequiredFields.Comment)
  584. return `<div class="form-group n4">` +
  585. `<div class="row">` +
  586. `<div class="col-md-3">` +
  587. `<label for="lbl_price-fomat">Order require fields</label>` +
  588. `</div>` +
  589. `<div class="col-md-9">` +
  590. `<div>` +
  591. checkboxes +
  592. `</div>` +
  593. `</div>` +
  594. `</div>` +
  595. `</div>`
  596. },
  597. },
  598. {
  599. Kind: builder.DFKCheckBox,
  600. Caption: "Accept orders",
  601. Name: "accept-orders",
  602. Value: utils.IntToStr((*wrap.Config).Shop.Orders.Enabled),
  603. },
  604. {
  605. Kind: builder.DFKText,
  606. Caption: "New order notify email",
  607. Name: "new-order-notify-email",
  608. Value: (*wrap.Config).Shop.Orders.NotifyEmail,
  609. Hint: "Example: example@gmail.com",
  610. },
  611. {
  612. Kind: builder.DFKText,
  613. Caption: "New order email theme (CP)",
  614. Name: "new-order-email-theme-cp",
  615. Value: (*wrap.Config).Shop.Orders.NewOrderEmailThemeCp,
  616. },
  617. {
  618. Kind: builder.DFKText,
  619. Caption: "New order email theme (User)",
  620. Name: "new-order-email-theme-user",
  621. Value: (*wrap.Config).Shop.Orders.NewOrderEmailThemeUser,
  622. },
  623. {
  624. Kind: builder.DFKCheckBox,
  625. Caption: "Custom field 1 enabled",
  626. Name: "custom-field-1-enabled",
  627. Value: utils.IntToStr((*wrap.Config).Shop.CustomFields.Field1.Enabled),
  628. },
  629. {
  630. Kind: builder.DFKText,
  631. Caption: "Custom field 1 caption",
  632. Name: "custom-field-1-caption",
  633. Value: (*wrap.Config).Shop.CustomFields.Field1.Caption,
  634. Hint: "Caption for product custom field",
  635. },
  636. {
  637. Kind: builder.DFKCheckBox,
  638. Caption: "Custom field 2 enabled",
  639. Name: "custom-field-2-enabled",
  640. Value: utils.IntToStr((*wrap.Config).Shop.CustomFields.Field2.Enabled),
  641. },
  642. {
  643. Kind: builder.DFKText,
  644. Caption: "Custom field 2 caption",
  645. Name: "custom-field-2-caption",
  646. Value: (*wrap.Config).Shop.CustomFields.Field2.Caption,
  647. Hint: "Caption for product custom field",
  648. },
  649. {
  650. Kind: builder.DFKSubmit,
  651. Value: "Save",
  652. Target: "add-edit-button",
  653. },
  654. })
  655. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  656. } else if wrap.CurrSubModule == "api" {
  657. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  658. {Name: "API"},
  659. })
  660. content += builder.DataForm(wrap, []builder.DataFormField{
  661. {
  662. Kind: builder.DFKHidden,
  663. Name: "action",
  664. Value: "settings-api",
  665. },
  666. {
  667. Kind: builder.DFKCheckBox,
  668. Caption: "XML enabled",
  669. Name: "xml-enabled",
  670. Value: utils.IntToStr((*wrap.Config).API.XML.Enabled),
  671. Hint: "XML: <a href=\"/api/products/\" target=\"_blank\">/api/products/</a>",
  672. },
  673. {
  674. Kind: builder.DFKText,
  675. Caption: "XML name",
  676. Name: "xml-name",
  677. Value: (*wrap.Config).API.XML.Name,
  678. },
  679. {
  680. Kind: builder.DFKText,
  681. Caption: "XML company",
  682. Name: "xml-company",
  683. Value: (*wrap.Config).API.XML.Company,
  684. },
  685. {
  686. Kind: builder.DFKText,
  687. Caption: "XML url",
  688. Name: "xml-url",
  689. Value: (*wrap.Config).API.XML.Url,
  690. },
  691. {
  692. Kind: builder.DFKSubmit,
  693. Value: "Save",
  694. Target: "add-edit-button",
  695. },
  696. })
  697. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  698. }
  699. return this.getSidebarModules(wrap), content, sidebar
  700. })
  701. }