module_shop.go 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
  1. package modules
  2. import (
  3. "html"
  4. "net/http"
  5. "strings"
  6. "golang-fave/assets"
  7. "golang-fave/consts"
  8. "golang-fave/engine/builder"
  9. "golang-fave/engine/fetdata"
  10. "golang-fave/engine/sqlw"
  11. "golang-fave/engine/wrapper"
  12. "golang-fave/utils"
  13. )
  14. func (this *Modules) shop_GetCurrencySelectOptions(wrap *wrapper.Wrapper, id int) string {
  15. result := ``
  16. rows, err := wrap.DB.Query(
  17. `SELECT
  18. id,
  19. code
  20. FROM
  21. shop_currencies
  22. ORDER BY
  23. id ASC
  24. ;`,
  25. )
  26. if err == nil {
  27. defer rows.Close()
  28. values := make([]string, 2)
  29. scan := make([]interface{}, len(values))
  30. for i := range values {
  31. scan[i] = &values[i]
  32. }
  33. idStr := utils.IntToStr(id)
  34. for rows.Next() {
  35. err = rows.Scan(scan...)
  36. if err == nil {
  37. selected := ""
  38. if string(values[0]) == idStr {
  39. selected = " selected"
  40. }
  41. result += `<option title="` + html.EscapeString(string(values[1])) + `" value="` + html.EscapeString(string(values[0])) + `"` + selected + `>` + html.EscapeString(string(values[1])) + `</option>`
  42. }
  43. }
  44. }
  45. return result
  46. }
  47. func (this *Modules) shop_GetProductValuesInputs(wrap *wrapper.Wrapper, product_id int) string {
  48. result := ``
  49. rows, err := wrap.DB.Query(
  50. `SELECT
  51. shop_filters.id,
  52. shop_filters.name,
  53. shop_filters_values.id,
  54. shop_filters_values.name,
  55. IF(shop_filter_product_values.filter_value_id > 0, 1, 0) as selected
  56. FROM
  57. shop_filters
  58. LEFT JOIN shop_filters_values ON shop_filters_values.filter_id = shop_filters.id
  59. LEFT JOIN shop_filter_product_values ON shop_filter_product_values.filter_value_id = shop_filters_values.id
  60. LEFT JOIN (
  61. SELECT
  62. shop_filters_values.filter_id,
  63. shop_filter_product_values.product_id
  64. FROM
  65. shop_filter_product_values
  66. LEFT JOIN shop_filters_values ON shop_filters_values.id = shop_filter_product_values.filter_value_id
  67. WHERE
  68. shop_filter_product_values.product_id = ` + utils.IntToStr(product_id) + `
  69. GROUP BY
  70. shop_filters_values.filter_id
  71. ) as filter_used ON filter_used.filter_id = shop_filters.id
  72. WHERE
  73. (
  74. shop_filter_product_values.product_id = ` + utils.IntToStr(product_id) + ` OR
  75. shop_filter_product_values.product_id IS NULL
  76. ) AND
  77. filter_used.filter_id IS NOT NULL
  78. ORDER BY
  79. shop_filters.name ASC,
  80. shop_filters_values.name ASC
  81. ;`,
  82. )
  83. filter_ids := []int{}
  84. filter_names := map[int]string{}
  85. filter_values := map[int][]string{}
  86. if err == nil {
  87. defer rows.Close()
  88. values := make([]string, 5)
  89. scan := make([]interface{}, len(values))
  90. for i := range values {
  91. scan[i] = &values[i]
  92. }
  93. for rows.Next() {
  94. err = rows.Scan(scan...)
  95. if err == nil {
  96. filter_id := utils.StrToInt(string(values[0]))
  97. if !utils.InArrayInt(filter_ids, filter_id) {
  98. filter_ids = append(filter_ids, filter_id)
  99. }
  100. filter_names[filter_id] = html.EscapeString(string(values[1]))
  101. selected := ``
  102. if utils.StrToInt(string(values[4])) == 1 {
  103. selected = ` selected`
  104. }
  105. filter_values[filter_id] = append(filter_values[filter_id], `<option value="`+html.EscapeString(string(values[2]))+`"`+selected+`>`+html.EscapeString(string(values[3]))+`</option>`)
  106. }
  107. }
  108. }
  109. for _, filter_id := range filter_ids {
  110. result += `<div class="form-group" id="prod_attr_` + utils.IntToStr(filter_id) + `">` +
  111. `<div><b>` + filter_names[filter_id] + `</b></div>` +
  112. `<div class="position-relative">` +
  113. `<select class="selectpicker form-control" name="value.` + utils.IntToStr(filter_id) + `" autocomplete="off" required multiple>` +
  114. strings.Join(filter_values[filter_id], "") +
  115. `</select>` +
  116. `<button type="button" class="btn btn-danger btn-dynamic-remove" onclick="fave.ShopProductsRemove(this);">&times;</button>` +
  117. `</div>` +
  118. `</div>`
  119. }
  120. return result
  121. }
  122. func (this *Modules) shop_GetFilterValuesInputs(wrap *wrapper.Wrapper, filter_id int) string {
  123. result := ``
  124. rows, err := wrap.DB.Query(
  125. `SELECT
  126. id,
  127. name
  128. FROM
  129. shop_filters_values
  130. WHERE
  131. filter_id = ?
  132. ORDER BY
  133. name ASC
  134. ;`,
  135. filter_id,
  136. )
  137. if err == nil {
  138. defer rows.Close()
  139. values := make([]string, 2)
  140. scan := make([]interface{}, len(values))
  141. for i := range values {
  142. scan[i] = &values[i]
  143. }
  144. for rows.Next() {
  145. err = rows.Scan(scan...)
  146. if err == nil {
  147. result += `<div class="form-group position-relative"><input class="form-control" type="text" name="value.` + html.EscapeString(string(values[0])) + `" value="` + html.EscapeString(string(values[1])) + `" placeholder="" autocomplete="off" required><button type="button" class="btn btn-danger btn-dynamic-remove" onclick="fave.ShopAttributesRemove(this);">&times;</button></div>`
  148. }
  149. }
  150. }
  151. return result
  152. }
  153. func (this *Modules) shop_GetAllAttributesSelectOptions(wrap *wrapper.Wrapper) string {
  154. result := ``
  155. rows, err := wrap.DB.Query(
  156. `SELECT
  157. id,
  158. name,
  159. filter
  160. FROM
  161. shop_filters
  162. ORDER BY
  163. name ASC
  164. ;`,
  165. )
  166. result += `<option title="&mdash;" value="0">&mdash;</option>`
  167. if err == nil {
  168. defer rows.Close()
  169. values := make([]string, 3)
  170. scan := make([]interface{}, len(values))
  171. for i := range values {
  172. scan[i] = &values[i]
  173. }
  174. for rows.Next() {
  175. err = rows.Scan(scan...)
  176. if err == nil {
  177. result += `<option title="` + html.EscapeString(string(values[1])) + `" value="` + html.EscapeString(string(values[0])) + `">` + html.EscapeString(string(values[1])) + `</option>`
  178. }
  179. }
  180. }
  181. return result
  182. }
  183. func (this *Modules) shop_GetAllCurrencies(wrap *wrapper.Wrapper) map[int]string {
  184. result := map[int]string{}
  185. rows, err := wrap.DB.Query(
  186. `SELECT
  187. id,
  188. code
  189. FROM
  190. shop_currencies
  191. ORDER BY
  192. id ASC
  193. ;`,
  194. )
  195. if err == nil {
  196. defer rows.Close()
  197. values := make([]string, 2)
  198. scan := make([]interface{}, len(values))
  199. for i := range values {
  200. scan[i] = &values[i]
  201. }
  202. for rows.Next() {
  203. err = rows.Scan(scan...)
  204. if err == nil {
  205. result[utils.StrToInt(string(values[0]))] = html.EscapeString(string(values[1]))
  206. }
  207. }
  208. }
  209. return result
  210. }
  211. func (this *Modules) shop_GetAllProductImages(wrap *wrapper.Wrapper, product_id int) string {
  212. result := ``
  213. rows, err := wrap.DB.Query(
  214. `SELECT
  215. product_id,
  216. filename
  217. FROM
  218. shop_product_images
  219. WHERE
  220. product_id = ?
  221. ;`,
  222. product_id,
  223. )
  224. if err == nil {
  225. defer rows.Close()
  226. values := make([]string, 2)
  227. scan := make([]interface{}, len(values))
  228. for i := range values {
  229. scan[i] = &values[i]
  230. }
  231. for rows.Next() {
  232. err = rows.Scan(scan...)
  233. if err == nil {
  234. result += `<div class="attached-img"><a href="/products/images/` + html.EscapeString(string(values[0])) + `/` + html.EscapeString(string(values[1])) + `" target="_blank">` + html.EscapeString(string(values[1])) + `</a>, <a href="javascript:fave.ShopProductsDeleteImage(this, ` + html.EscapeString(string(values[0])) + `, '` + html.EscapeString(string(values[1])) + `');">Delete</a></div>`
  235. }
  236. }
  237. }
  238. return result
  239. }
  240. func (this *Modules) RegisterModule_Shop() *Module {
  241. return this.newModule(MInfo{
  242. WantDB: true,
  243. Mount: "shop",
  244. Name: "Shop",
  245. Order: 2,
  246. System: false,
  247. Icon: assets.SysSvgIconList,
  248. Sub: &[]MISub{
  249. {Mount: "default", Name: "List of products", Show: true, Icon: assets.SysSvgIconList},
  250. {Mount: "add", Name: "Add new product", Show: true, Icon: assets.SysSvgIconPlus},
  251. {Mount: "modify", Name: "Modify product", Show: false},
  252. {Sep: true, Show: true},
  253. {Mount: "categories", Name: "List of categories", Show: true, Icon: assets.SysSvgIconList},
  254. {Mount: "categories-add", Name: "Add new category", Show: true, Icon: assets.SysSvgIconPlus},
  255. {Mount: "categories-modify", Name: "Modify category", Show: false},
  256. {Sep: true, Show: true},
  257. {Mount: "attributes", Name: "List of attributes", Show: true, Icon: assets.SysSvgIconList},
  258. {Mount: "attributes-add", Name: "Add new attribute", Show: true, Icon: assets.SysSvgIconPlus},
  259. {Mount: "attributes-modify", Name: "Modify attribute", Show: false},
  260. {Sep: true, Show: true},
  261. {Mount: "currencies", Name: "List of currencies", Show: true, Icon: assets.SysSvgIconList},
  262. {Mount: "currencies-add", Name: "Add new currency", Show: true, Icon: assets.SysSvgIconPlus},
  263. {Mount: "currencies-modify", Name: "Modify currency", Show: false},
  264. },
  265. }, func(wrap *wrapper.Wrapper) {
  266. if len(wrap.UrlArgs) == 3 && wrap.UrlArgs[0] == "shop" && wrap.UrlArgs[1] == "category" && wrap.UrlArgs[2] != "" {
  267. // Shop category
  268. row := &utils.MySql_shop_category{}
  269. err := wrap.DB.QueryRow(`
  270. SELECT
  271. id,
  272. user,
  273. name,
  274. alias,
  275. lft,
  276. rgt
  277. FROM
  278. shop_cats
  279. WHERE
  280. alias = ? AND
  281. id > 1
  282. LIMIT 1;`,
  283. wrap.UrlArgs[2],
  284. ).Scan(
  285. &row.A_id,
  286. &row.A_user,
  287. &row.A_name,
  288. &row.A_alias,
  289. &row.A_lft,
  290. &row.A_rgt,
  291. )
  292. if err != nil && err != wrapper.ErrNoRows {
  293. // System error 500
  294. utils.SystemErrorPageEngine(wrap.W, err)
  295. return
  296. } else if err == wrapper.ErrNoRows {
  297. // User error 404 page
  298. wrap.RenderFrontEnd("404", fetdata.New(wrap, nil, true), http.StatusNotFound)
  299. return
  300. }
  301. // Fix url
  302. if wrap.R.URL.Path[len(wrap.R.URL.Path)-1] != '/' {
  303. http.Redirect(wrap.W, wrap.R, wrap.R.URL.Path+"/"+utils.ExtractGetParams(wrap.R.RequestURI), 301)
  304. return
  305. }
  306. // Render template
  307. wrap.RenderFrontEnd("shop-category", fetdata.New(wrap, row, false), http.StatusOK)
  308. return
  309. } else if len(wrap.UrlArgs) == 2 && wrap.UrlArgs[0] == "shop" && wrap.UrlArgs[1] != "" {
  310. // Shop product
  311. row := &utils.MySql_shop_product{}
  312. err := wrap.DB.QueryRow(`
  313. SELECT
  314. id,
  315. user,
  316. currency,
  317. price,
  318. name,
  319. alias,
  320. briefly,
  321. content,
  322. UNIX_TIMESTAMP(datetime) as datetime,
  323. active
  324. FROM
  325. shop_products
  326. WHERE
  327. active = 1 and
  328. alias = ?
  329. LIMIT 1;`,
  330. wrap.UrlArgs[1],
  331. ).Scan(
  332. &row.A_id,
  333. &row.A_user,
  334. &row.A_currency,
  335. &row.A_price,
  336. &row.A_name,
  337. &row.A_alias,
  338. &row.A_briefly,
  339. &row.A_content,
  340. &row.A_datetime,
  341. &row.A_active,
  342. )
  343. if err != nil && err != wrapper.ErrNoRows {
  344. // System error 500
  345. utils.SystemErrorPageEngine(wrap.W, err)
  346. return
  347. } else if err == wrapper.ErrNoRows {
  348. // User error 404 page
  349. wrap.RenderFrontEnd("404", fetdata.New(wrap, nil, true), http.StatusNotFound)
  350. return
  351. }
  352. // Fix url
  353. if wrap.R.URL.Path[len(wrap.R.URL.Path)-1] != '/' {
  354. http.Redirect(wrap.W, wrap.R, wrap.R.URL.Path+"/"+utils.ExtractGetParams(wrap.R.RequestURI), 301)
  355. return
  356. }
  357. // Render template
  358. wrap.RenderFrontEnd("shop-product", fetdata.New(wrap, row, false), http.StatusOK)
  359. return
  360. } else if len(wrap.UrlArgs) == 1 && wrap.UrlArgs[0] == "shop" {
  361. // Shop
  362. // Fix url
  363. if wrap.R.URL.Path[len(wrap.R.URL.Path)-1] != '/' {
  364. http.Redirect(wrap.W, wrap.R, wrap.R.URL.Path+"/"+utils.ExtractGetParams(wrap.R.RequestURI), 301)
  365. return
  366. }
  367. // Render template
  368. wrap.RenderFrontEnd("shop", fetdata.New(wrap, nil, false), http.StatusOK)
  369. return
  370. }
  371. // User error 404 page
  372. wrap.RenderFrontEnd("404", fetdata.New(wrap, nil, true), http.StatusNotFound)
  373. }, func(wrap *wrapper.Wrapper) (string, string, string) {
  374. content := ""
  375. sidebar := ""
  376. if wrap.CurrSubModule == "" || wrap.CurrSubModule == "default" {
  377. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  378. {Name: "List of products"},
  379. })
  380. // Load currencies
  381. currencies := this.shop_GetAllCurrencies(wrap)
  382. content += builder.DataTable(
  383. wrap,
  384. "shop_products",
  385. "id",
  386. "DESC",
  387. &[]builder.DataTableRow{
  388. {
  389. DBField: "id",
  390. },
  391. {
  392. DBField: "name",
  393. NameInTable: "Product / URL",
  394. CallBack: func(values *[]string) string {
  395. name := `<a href="/cp/` + wrap.CurrModule + `/modify/` + (*values)[0] + `/">` + html.EscapeString((*values)[1]) + `</a>`
  396. alias := html.EscapeString((*values)[2])
  397. return `<div>` + name + `</div><div><small>/shop/` + alias + `/</small></div>`
  398. },
  399. },
  400. {
  401. DBField: "alias",
  402. },
  403. {
  404. DBField: "currency",
  405. },
  406. {
  407. DBField: "price",
  408. NameInTable: "Price",
  409. Classes: "d-none d-md-table-cell",
  410. CallBack: func(values *[]string) string {
  411. return `<div>` + utils.Float64ToStr(utils.StrToFloat64((*values)[4])) + `</div>` +
  412. `<div><small>` + currencies[utils.StrToInt((*values)[3])] + `</small></div>`
  413. },
  414. },
  415. {
  416. DBField: "datetime",
  417. DBExp: "UNIX_TIMESTAMP(`datetime`)",
  418. NameInTable: "Date / Time",
  419. Classes: "d-none d-lg-table-cell",
  420. CallBack: func(values *[]string) string {
  421. t := int64(utils.StrToInt((*values)[5]))
  422. return `<div>` + utils.UnixTimestampToFormat(t, "02.01.2006") + `</div>` +
  423. `<div><small>` + utils.UnixTimestampToFormat(t, "15:04:05") + `</small></div>`
  424. },
  425. },
  426. {
  427. DBField: "active",
  428. NameInTable: "Active",
  429. Classes: "d-none d-sm-table-cell",
  430. CallBack: func(values *[]string) string {
  431. return builder.CheckBox(utils.StrToInt((*values)[6]))
  432. },
  433. },
  434. },
  435. func(values *[]string) string {
  436. return builder.DataTableAction(&[]builder.DataTableActionRow{
  437. {
  438. Icon: assets.SysSvgIconView,
  439. Href: `/shop/` + (*values)[2] + `/`,
  440. Hint: "View",
  441. Target: "_blank",
  442. },
  443. {
  444. Icon: assets.SysSvgIconEdit,
  445. Href: "/cp/" + wrap.CurrModule + "/modify/" + (*values)[0] + "/",
  446. Hint: "Edit",
  447. },
  448. {
  449. Icon: assets.SysSvgIconRemove,
  450. Href: "javascript:fave.ActionDataTableDelete(this,'shop-delete','" +
  451. (*values)[0] + "','Are you sure want to delete product?');",
  452. Hint: "Delete",
  453. Classes: "delete",
  454. },
  455. })
  456. },
  457. "/cp/"+wrap.CurrModule+"/",
  458. nil,
  459. nil,
  460. true,
  461. )
  462. } else if wrap.CurrSubModule == "categories" {
  463. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  464. {Name: "Categories", Link: "/cp/" + wrap.CurrModule + "/" + wrap.CurrSubModule + "/"},
  465. {Name: "List of categories"},
  466. })
  467. content += builder.DataTable(
  468. wrap,
  469. "shop_cats",
  470. "id",
  471. "ASC",
  472. &[]builder.DataTableRow{
  473. {
  474. DBField: "id",
  475. },
  476. {
  477. DBField: "user",
  478. },
  479. {
  480. DBField: "name",
  481. NameInTable: "Category",
  482. CallBack: func(values *[]string) string {
  483. depth := utils.StrToInt((*values)[4]) - 1
  484. if depth < 0 {
  485. depth = 0
  486. }
  487. sub := strings.Repeat("&mdash; ", depth)
  488. name := `<a href="/cp/` + wrap.CurrModule + `/categories-modify/` + (*values)[0] + `/">` + sub + html.EscapeString((*values)[2]) + `</a>`
  489. return `<div>` + name + `</div>`
  490. },
  491. },
  492. {
  493. DBField: "alias",
  494. },
  495. {
  496. DBField: "depth",
  497. },
  498. },
  499. func(values *[]string) string {
  500. return builder.DataTableAction(&[]builder.DataTableActionRow{
  501. {
  502. Icon: assets.SysSvgIconView,
  503. Href: `/shop/category/` + (*values)[3] + `/`,
  504. Hint: "View",
  505. Target: "_blank",
  506. },
  507. {
  508. Icon: assets.SysSvgIconEdit,
  509. Href: "/cp/" + wrap.CurrModule + "/categories-modify/" + (*values)[0] + "/",
  510. Hint: "Edit",
  511. },
  512. {
  513. Icon: assets.SysSvgIconRemove,
  514. Href: "javascript:fave.ActionDataTableDelete(this,'shop-categories-delete','" +
  515. (*values)[0] + "','Are you sure want to delete category?');",
  516. Hint: "Delete",
  517. Classes: "delete",
  518. },
  519. })
  520. },
  521. "/cp/"+wrap.CurrModule+"/"+wrap.CurrSubModule+"/",
  522. nil,
  523. func(limit_offset int, pear_page int) (*sqlw.Rows, error) {
  524. return wrap.DB.Query(
  525. `SELECT
  526. node.id,
  527. node.user,
  528. node.name,
  529. node.alias,
  530. (COUNT(parent.id) - 1) AS depth
  531. FROM
  532. shop_cats AS node,
  533. shop_cats AS parent
  534. WHERE
  535. node.lft BETWEEN parent.lft AND parent.rgt AND
  536. node.id > 1
  537. GROUP BY
  538. node.id
  539. ORDER BY
  540. node.lft ASC
  541. ;`,
  542. )
  543. },
  544. false,
  545. )
  546. } else if wrap.CurrSubModule == "attributes" {
  547. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  548. {Name: "Attributes", Link: "/cp/" + wrap.CurrModule + "/" + wrap.CurrSubModule + "/"},
  549. {Name: "List of attributes"},
  550. })
  551. content += builder.DataTable(
  552. wrap,
  553. "shop_filters",
  554. "id",
  555. "DESC",
  556. &[]builder.DataTableRow{
  557. {
  558. DBField: "id",
  559. },
  560. {
  561. DBField: "name",
  562. NameInTable: "Name",
  563. CallBack: func(values *[]string) string {
  564. name := `<a href="/cp/` + wrap.CurrModule + `/attributes-modify/` + (*values)[0] + `/">` + html.EscapeString((*values)[1]) + `</a>`
  565. return `<div>` + name + `</div><div><small>` + html.EscapeString((*values)[2]) + `</small></div>`
  566. },
  567. },
  568. {
  569. DBField: "filter",
  570. },
  571. },
  572. func(values *[]string) string {
  573. return builder.DataTableAction(&[]builder.DataTableActionRow{
  574. {
  575. Icon: assets.SysSvgIconEdit,
  576. Href: "/cp/" + wrap.CurrModule + "/attributes-modify/" + (*values)[0] + "/",
  577. Hint: "Edit",
  578. },
  579. {
  580. Icon: assets.SysSvgIconRemove,
  581. Href: "javascript:fave.ActionDataTableDelete(this,'shop-attributes-delete','" +
  582. (*values)[0] + "','Are you sure want to delete attribute?');",
  583. Hint: "Delete",
  584. Classes: "delete",
  585. },
  586. })
  587. },
  588. "/cp/"+wrap.CurrModule+"/"+wrap.CurrSubModule+"/",
  589. nil,
  590. nil,
  591. true,
  592. )
  593. } else if wrap.CurrSubModule == "currencies" {
  594. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  595. {Name: "Currencies", Link: "/cp/" + wrap.CurrModule + "/" + wrap.CurrSubModule + "/"},
  596. {Name: "List of currencies"},
  597. })
  598. content += builder.DataTable(
  599. wrap,
  600. "shop_currencies",
  601. "id",
  602. "DESC",
  603. &[]builder.DataTableRow{
  604. {
  605. DBField: "id",
  606. },
  607. {
  608. DBField: "name",
  609. NameInTable: "Name",
  610. CallBack: func(values *[]string) string {
  611. name := `<a href="/cp/` + wrap.CurrModule + `/currencies-modify/` + (*values)[0] + `/">` + html.EscapeString((*values)[1]) + ` (` + (*values)[3] + `, ` + (*values)[4] + `)</a>`
  612. return `<div>` + name + `</div>`
  613. },
  614. },
  615. {
  616. DBField: "coefficient",
  617. NameInTable: "Coefficient",
  618. Classes: "d-none d-md-table-cell",
  619. CallBack: func(values *[]string) string {
  620. return utils.Float64ToStrF(utils.StrToFloat64((*values)[2]), "%.4f")
  621. },
  622. },
  623. {
  624. DBField: "code",
  625. },
  626. {
  627. DBField: "symbol",
  628. },
  629. },
  630. func(values *[]string) string {
  631. return builder.DataTableAction(&[]builder.DataTableActionRow{
  632. {
  633. Icon: assets.SysSvgIconEdit,
  634. Href: "/cp/" + wrap.CurrModule + "/currencies-modify/" + (*values)[0] + "/",
  635. Hint: "Edit",
  636. },
  637. {
  638. Icon: assets.SysSvgIconRemove,
  639. Href: "javascript:fave.ActionDataTableDelete(this,'shop-currencies-delete','" +
  640. (*values)[0] + "','Are you sure want to delete currency?');",
  641. Hint: "Delete",
  642. Classes: "delete",
  643. },
  644. })
  645. },
  646. "/cp/"+wrap.CurrModule+"/"+wrap.CurrSubModule+"/",
  647. nil,
  648. nil,
  649. true,
  650. )
  651. } else if wrap.CurrSubModule == "add" || wrap.CurrSubModule == "modify" {
  652. if wrap.CurrSubModule == "add" {
  653. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  654. {Name: "Add new product"},
  655. })
  656. } else {
  657. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  658. {Name: "Modify product"},
  659. })
  660. }
  661. data := utils.MySql_shop_product{
  662. A_id: 0,
  663. A_user: 0,
  664. A_name: "",
  665. A_alias: "",
  666. A_content: "",
  667. A_datetime: 0,
  668. A_active: 0,
  669. }
  670. if wrap.CurrSubModule == "modify" {
  671. if len(wrap.UrlArgs) != 3 {
  672. return "", "", ""
  673. }
  674. if !utils.IsNumeric(wrap.UrlArgs[2]) {
  675. return "", "", ""
  676. }
  677. err := wrap.DB.QueryRow(`
  678. SELECT
  679. id,
  680. user,
  681. currency,
  682. price,
  683. name,
  684. alias,
  685. briefly,
  686. content,
  687. active
  688. FROM
  689. shop_products
  690. WHERE
  691. id = ?
  692. LIMIT 1;`,
  693. utils.StrToInt(wrap.UrlArgs[2]),
  694. ).Scan(
  695. &data.A_id,
  696. &data.A_user,
  697. &data.A_currency,
  698. &data.A_price,
  699. &data.A_name,
  700. &data.A_alias,
  701. &data.A_briefly,
  702. &data.A_content,
  703. &data.A_active,
  704. )
  705. if err != nil {
  706. return "", "", ""
  707. }
  708. }
  709. // All product current categories
  710. var selids []int
  711. if data.A_id > 0 {
  712. rows, err := wrap.DB.Query("SELECT category_id FROM shop_cat_product_rel WHERE product_id = ?;", data.A_id)
  713. if err == nil {
  714. defer rows.Close()
  715. values := make([]int, 1)
  716. scan := make([]interface{}, len(values))
  717. for i := range values {
  718. scan[i] = &values[i]
  719. }
  720. for rows.Next() {
  721. err = rows.Scan(scan...)
  722. if err == nil {
  723. selids = append(selids, int(values[0]))
  724. }
  725. }
  726. }
  727. }
  728. btn_caption := "Add"
  729. if wrap.CurrSubModule == "modify" {
  730. btn_caption = "Save"
  731. }
  732. content += builder.DataForm(wrap, []builder.DataFormField{
  733. {
  734. Kind: builder.DFKHidden,
  735. Name: "action",
  736. Value: "shop-modify",
  737. },
  738. {
  739. Kind: builder.DFKHidden,
  740. Name: "id",
  741. Value: utils.IntToStr(data.A_id),
  742. },
  743. {
  744. Kind: builder.DFKText,
  745. Caption: "Product name",
  746. Name: "name",
  747. Value: data.A_name,
  748. Required: true,
  749. Min: "1",
  750. Max: "255",
  751. },
  752. {
  753. Kind: builder.DFKText,
  754. Caption: "Product price",
  755. Name: "price",
  756. Value: "0",
  757. CallBack: func(field *builder.DataFormField) string {
  758. return `<div class="form-group n3">` +
  759. `<div class="row">` +
  760. `<div class="col-md-3">` +
  761. `<label for="lbl_price">Product price</label>` +
  762. `</div>` +
  763. `<div class="col-md-9">` +
  764. `<div>` +
  765. `<div class="row">` +
  766. `<div class="col-md-8">` +
  767. `<div><input class="form-control" type="number" step="0.01" id="lbl_price" name="price" value="` + utils.Float64ToStr(data.A_price) + `" placeholder="" autocomplete="off" required></div>` +
  768. `<div class="d-md-none mb-3"></div>` +
  769. `</div>` +
  770. `<div class="col-md-4">` +
  771. `<select class="selectpicker form-control" id="lbl_currency" name="currency" data-live-search="true">` +
  772. this.shop_GetCurrencySelectOptions(wrap, data.A_currency) +
  773. `</select>` +
  774. `</div>` +
  775. `</div>` +
  776. `</div>` +
  777. `</div>` +
  778. `</div>` +
  779. `</div>`
  780. },
  781. },
  782. {
  783. Kind: builder.DFKText,
  784. Caption: "Product alias",
  785. Name: "alias",
  786. Value: data.A_alias,
  787. Hint: "Example: mobile-phone",
  788. Max: "255",
  789. },
  790. {
  791. Kind: builder.DFKText,
  792. Caption: "Categories",
  793. Name: "cats",
  794. Value: "0",
  795. CallBack: func(field *builder.DataFormField) string {
  796. return `<div class="form-group n5">` +
  797. `<div class="row">` +
  798. `<div class="col-md-3">` +
  799. `<label for="lbl_parent">Categories</label>` +
  800. `</div>` +
  801. `<div class="col-md-9">` +
  802. `<div>` +
  803. `<select class="selectpicker form-control" id="lbl_cats" name="cats[]" data-live-search="true" multiple>` +
  804. this.shop_GetCategorySelectOptions(wrap, 0, 0, selids) +
  805. `</select>` +
  806. `</div>` +
  807. `</div>` +
  808. `</div>` +
  809. `</div>`
  810. },
  811. },
  812. {
  813. Kind: builder.DFKText,
  814. Caption: "Attributes",
  815. Name: "",
  816. Value: "",
  817. CallBack: func(field *builder.DataFormField) string {
  818. return `<div class="form-group n6">` +
  819. `<div class="row">` +
  820. `<div class="col-md-3">` +
  821. `<label>Attributes</label>` +
  822. `</div>` +
  823. `<div class="col-md-9">` +
  824. `<div class="list-wrapper">` +
  825. `<div id="list">` +
  826. this.shop_GetProductValuesInputs(wrap, data.A_id) +
  827. `</div>` +
  828. `<div class="list-button position-relative">` +
  829. `<select class="selectpicker form-control" id="lbl_attributes" data-live-search="true">` +
  830. this.shop_GetAllAttributesSelectOptions(wrap) +
  831. `</select>` +
  832. `<button type="button" class="btn btn-success btn-dynamic-remove" onclick="fave.ShopProductsAdd();">Add attribute</button>` +
  833. `</div>` +
  834. `</div>` +
  835. `</div>` +
  836. `</div>` +
  837. `</div>`
  838. },
  839. },
  840. {
  841. Kind: builder.DFKTextArea,
  842. Caption: "Briefly",
  843. Name: "briefly",
  844. Value: data.A_briefly,
  845. Classes: "briefly wysiwyg",
  846. },
  847. {
  848. Kind: builder.DFKTextArea,
  849. Caption: "Product content",
  850. Name: "content",
  851. Value: data.A_content,
  852. Classes: "wysiwyg",
  853. },
  854. {
  855. Kind: builder.DFKText,
  856. Caption: "Product images",
  857. Name: "",
  858. Value: "",
  859. CallBack: func(field *builder.DataFormField) string {
  860. if data.A_id == 0 {
  861. return ``
  862. }
  863. return `<div class="form-group n6">` +
  864. `<div class="row">` +
  865. `<div class="col-md-3">` +
  866. `<label>Product images</label>` +
  867. `</div>` +
  868. `<div class="col-md-9">` +
  869. `<div class="list-wrapper">` +
  870. `<div id="list-images">` +
  871. this.shop_GetAllProductImages(wrap, data.A_id) +
  872. `</div>` +
  873. `<div class="list-button position-relative">` +
  874. `<input class="form-control" type="file" id="file" name="file" style="font-size:13px;" /><button type="button" class="btn btn-success btn-dynamic-remove" onclick="fave.ShopProductsUploadImage('shop-upload-image', ` + utils.IntToStr(data.A_id) + `, 'file');">Upload</button>` +
  875. `</div>` +
  876. `</div>` +
  877. `</div>` +
  878. `</div>` +
  879. `</div>`
  880. },
  881. },
  882. {
  883. Kind: builder.DFKCheckBox,
  884. Caption: "Active",
  885. Name: "active",
  886. Value: utils.IntToStr(data.A_active),
  887. },
  888. {
  889. Kind: builder.DFKSubmit,
  890. Value: btn_caption,
  891. Target: "add-edit-button",
  892. },
  893. })
  894. if wrap.CurrSubModule == "add" {
  895. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Add</button>`
  896. } else {
  897. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  898. }
  899. } else if wrap.CurrSubModule == "categories-add" || wrap.CurrSubModule == "categories-modify" {
  900. if wrap.CurrSubModule == "categories-add" {
  901. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  902. {Name: "Categories", Link: "/cp/" + wrap.CurrModule + "/categories/"},
  903. {Name: "Add new category"},
  904. })
  905. } else {
  906. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  907. {Name: "Categories", Link: "/cp/" + wrap.CurrModule + "/categories/"},
  908. {Name: "Modify category"},
  909. })
  910. }
  911. data := utils.MySql_shop_category{
  912. A_id: 0,
  913. A_user: 0,
  914. A_name: "",
  915. A_alias: "",
  916. A_lft: 0,
  917. A_rgt: 0,
  918. }
  919. if wrap.CurrSubModule == "categories-modify" {
  920. if len(wrap.UrlArgs) != 3 {
  921. return "", "", ""
  922. }
  923. if !utils.IsNumeric(wrap.UrlArgs[2]) {
  924. return "", "", ""
  925. }
  926. err := wrap.DB.QueryRow(`
  927. SELECT
  928. id,
  929. user,
  930. name,
  931. alias,
  932. lft,
  933. rgt
  934. FROM
  935. shop_cats
  936. WHERE
  937. id = ?
  938. LIMIT 1;`,
  939. utils.StrToInt(wrap.UrlArgs[2]),
  940. ).Scan(
  941. &data.A_id,
  942. &data.A_user,
  943. &data.A_name,
  944. &data.A_alias,
  945. &data.A_lft,
  946. &data.A_rgt,
  947. )
  948. if err != nil {
  949. return "", "", ""
  950. }
  951. }
  952. btn_caption := "Add"
  953. if wrap.CurrSubModule == "categories-modify" {
  954. btn_caption = "Save"
  955. }
  956. parentId := 0
  957. if wrap.CurrSubModule == "categories-modify" {
  958. parentId = this.shop_GetCategoryParentId(wrap, data.A_id)
  959. }
  960. content += builder.DataForm(wrap, []builder.DataFormField{
  961. {
  962. Kind: builder.DFKHidden,
  963. Name: "action",
  964. Value: "shop-categories-modify",
  965. },
  966. {
  967. Kind: builder.DFKHidden,
  968. Name: "id",
  969. Value: utils.IntToStr(data.A_id),
  970. },
  971. {
  972. Kind: builder.DFKText,
  973. Caption: "Parent",
  974. Name: "parent",
  975. Value: "0",
  976. CallBack: func(field *builder.DataFormField) string {
  977. return `<div class="form-group n2">` +
  978. `<div class="row">` +
  979. `<div class="col-md-3">` +
  980. `<label for="lbl_parent">Parent</label>` +
  981. `</div>` +
  982. `<div class="col-md-9">` +
  983. `<div>` +
  984. `<select class="selectpicker form-control" id="lbl_parent" name="parent" data-live-search="true">` +
  985. `<option title="Nothing selected" value="0">&mdash;</option>` +
  986. this.shop_GetCategorySelectOptions(wrap, data.A_id, parentId, []int{}) +
  987. `</select>` +
  988. `</div>` +
  989. `</div>` +
  990. `</div>` +
  991. `</div>`
  992. },
  993. },
  994. {
  995. Kind: builder.DFKText,
  996. Caption: "Name",
  997. Name: "name",
  998. Value: data.A_name,
  999. Required: true,
  1000. Min: "1",
  1001. Max: "255",
  1002. },
  1003. {
  1004. Kind: builder.DFKText,
  1005. Caption: "Alias",
  1006. Name: "alias",
  1007. Value: data.A_alias,
  1008. Hint: "Example: popular-products",
  1009. Max: "255",
  1010. },
  1011. {
  1012. Kind: builder.DFKSubmit,
  1013. Value: btn_caption,
  1014. Target: "add-edit-button",
  1015. },
  1016. })
  1017. if wrap.CurrSubModule == "categories-add" {
  1018. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Add</button>`
  1019. } else {
  1020. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  1021. }
  1022. } else if wrap.CurrSubModule == "attributes-add" || wrap.CurrSubModule == "attributes-modify" {
  1023. if wrap.CurrSubModule == "attributes-add" {
  1024. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  1025. {Name: "Attributes", Link: "/cp/" + wrap.CurrModule + "/attributes/"},
  1026. {Name: "Add new attribute"},
  1027. })
  1028. } else {
  1029. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  1030. {Name: "Attributes", Link: "/cp/" + wrap.CurrModule + "/attributes/"},
  1031. {Name: "Modify attribute"},
  1032. })
  1033. }
  1034. data := utils.MySql_shop_filter{
  1035. A_id: 0,
  1036. A_name: "",
  1037. A_filter: "",
  1038. }
  1039. if wrap.CurrSubModule == "attributes-modify" {
  1040. if len(wrap.UrlArgs) != 3 {
  1041. return "", "", ""
  1042. }
  1043. if !utils.IsNumeric(wrap.UrlArgs[2]) {
  1044. return "", "", ""
  1045. }
  1046. err := wrap.DB.QueryRow(`
  1047. SELECT
  1048. id,
  1049. name,
  1050. filter
  1051. FROM
  1052. shop_filters
  1053. WHERE
  1054. id = ?
  1055. LIMIT 1;`,
  1056. utils.StrToInt(wrap.UrlArgs[2]),
  1057. ).Scan(
  1058. &data.A_id,
  1059. &data.A_name,
  1060. &data.A_filter,
  1061. )
  1062. if err != nil {
  1063. return "", "", ""
  1064. }
  1065. }
  1066. btn_caption := "Add"
  1067. if wrap.CurrSubModule == "attributes-modify" {
  1068. btn_caption = "Save"
  1069. }
  1070. content += builder.DataForm(wrap, []builder.DataFormField{
  1071. {
  1072. Kind: builder.DFKHidden,
  1073. Name: "action",
  1074. Value: "shop-attributes-modify",
  1075. },
  1076. {
  1077. Kind: builder.DFKHidden,
  1078. Name: "id",
  1079. Value: utils.IntToStr(data.A_id),
  1080. },
  1081. {
  1082. Kind: builder.DFKText,
  1083. Caption: "Attribute name",
  1084. Name: "name",
  1085. Value: data.A_name,
  1086. Required: true,
  1087. Min: "1",
  1088. Max: "255",
  1089. },
  1090. {
  1091. Kind: builder.DFKText,
  1092. Caption: "Attribute in filter",
  1093. Name: "filter",
  1094. Value: data.A_filter,
  1095. Required: true,
  1096. Min: "1",
  1097. Max: "255",
  1098. },
  1099. {
  1100. Kind: builder.DFKText,
  1101. Caption: "Attribute values",
  1102. Name: "",
  1103. Value: "",
  1104. CallBack: func(field *builder.DataFormField) string {
  1105. return `<div class="form-group n4">` +
  1106. `<div class="row">` +
  1107. `<div class="col-md-3">` +
  1108. `<label>Attribute values</label>` +
  1109. `</div>` +
  1110. `<div class="col-md-9">` +
  1111. `<div class="list-wrapper">` +
  1112. `<div id="list">` +
  1113. this.shop_GetFilterValuesInputs(wrap, data.A_id) +
  1114. `</div>` +
  1115. `<div class="list-button"><button type="button" class="btn btn-success" onclick="fave.ShopAttributesAdd();">Add attribute value</button></div>` +
  1116. `</div>` +
  1117. `</div>` +
  1118. `</div>` +
  1119. `</div>`
  1120. },
  1121. },
  1122. {
  1123. Kind: builder.DFKSubmit,
  1124. Value: btn_caption,
  1125. Target: "add-edit-button",
  1126. },
  1127. })
  1128. if wrap.CurrSubModule == "attributes-add" {
  1129. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Add</button>`
  1130. } else {
  1131. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  1132. }
  1133. } else if wrap.CurrSubModule == "currencies-add" || wrap.CurrSubModule == "currencies-modify" {
  1134. if wrap.CurrSubModule == "currencies-add" {
  1135. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  1136. {Name: "Currencies", Link: "/cp/" + wrap.CurrModule + "/currencies/"},
  1137. {Name: "Add new currency"},
  1138. })
  1139. } else {
  1140. content += this.getBreadCrumbs(wrap, &[]consts.BreadCrumb{
  1141. {Name: "Currencies", Link: "/cp/" + wrap.CurrModule + "/currencies/"},
  1142. {Name: "Modify currency"},
  1143. })
  1144. }
  1145. data := utils.MySql_shop_currency{
  1146. A_id: 0,
  1147. A_name: "",
  1148. A_coefficient: 0,
  1149. A_code: "",
  1150. A_symbol: "",
  1151. }
  1152. if wrap.CurrSubModule == "currencies-modify" {
  1153. if len(wrap.UrlArgs) != 3 {
  1154. return "", "", ""
  1155. }
  1156. if !utils.IsNumeric(wrap.UrlArgs[2]) {
  1157. return "", "", ""
  1158. }
  1159. err := wrap.DB.QueryRow(`
  1160. SELECT
  1161. id,
  1162. name,
  1163. coefficient,
  1164. code,
  1165. symbol
  1166. FROM
  1167. shop_currencies
  1168. WHERE
  1169. id = ?
  1170. LIMIT 1;`,
  1171. utils.StrToInt(wrap.UrlArgs[2]),
  1172. ).Scan(
  1173. &data.A_id,
  1174. &data.A_name,
  1175. &data.A_coefficient,
  1176. &data.A_code,
  1177. &data.A_symbol,
  1178. )
  1179. if err != nil {
  1180. return "", "", ""
  1181. }
  1182. }
  1183. btn_caption := "Add"
  1184. if wrap.CurrSubModule == "currencies-modify" {
  1185. btn_caption = "Save"
  1186. }
  1187. content += builder.DataForm(wrap, []builder.DataFormField{
  1188. {
  1189. Kind: builder.DFKHidden,
  1190. Name: "action",
  1191. Value: "shop-currencies-modify",
  1192. },
  1193. {
  1194. Kind: builder.DFKHidden,
  1195. Name: "id",
  1196. Value: utils.IntToStr(data.A_id),
  1197. },
  1198. {
  1199. Kind: builder.DFKText,
  1200. Caption: "Currency name",
  1201. Name: "name",
  1202. Value: data.A_name,
  1203. Required: true,
  1204. Min: "1",
  1205. Max: "255",
  1206. },
  1207. {
  1208. Kind: builder.DFKText,
  1209. Caption: "Currency coefficient",
  1210. Name: "coefficient",
  1211. Value: "0",
  1212. CallBack: func(field *builder.DataFormField) string {
  1213. return `<div class="form-group n3">` +
  1214. `<div class="row">` +
  1215. `<div class="col-md-3">` +
  1216. `<label for="lbl_coefficient">Currency coefficient</label>` +
  1217. `</div>` +
  1218. `<div class="col-md-9">` +
  1219. `<div><input class="form-control" type="number" step="0.0001" id="lbl_coefficient" name="coefficient" value="` + utils.Float64ToStrF(data.A_coefficient, "%.4f") + `" placeholder="" autocomplete="off" required></div>` +
  1220. `</div>` +
  1221. `</div>` +
  1222. `</div>`
  1223. },
  1224. },
  1225. {
  1226. Kind: builder.DFKText,
  1227. Caption: "Currency code",
  1228. Name: "code",
  1229. Value: data.A_code,
  1230. Required: true,
  1231. Min: "1",
  1232. Max: "10",
  1233. },
  1234. {
  1235. Kind: builder.DFKText,
  1236. Caption: "Currency symbol",
  1237. Name: "symbol",
  1238. Value: data.A_symbol,
  1239. Required: true,
  1240. Min: "1",
  1241. Max: "5",
  1242. },
  1243. {
  1244. Kind: builder.DFKSubmit,
  1245. Value: btn_caption,
  1246. Target: "add-edit-button",
  1247. },
  1248. })
  1249. if wrap.CurrSubModule == "currencies-add" {
  1250. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Add</button>`
  1251. } else {
  1252. sidebar += `<button class="btn btn-primary btn-sidebar" id="add-edit-button">Save</button>`
  1253. }
  1254. }
  1255. return this.getSidebarModules(wrap), content, sidebar
  1256. })
  1257. }