EntityCrudRoutes.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. function getEntityCrudRouteObject(path, baseRouteName, componentPath, breadcrumbs) {
  2. const AllNeededRoutes = [
  3. { mode: 'Index', path: '' },
  4. { mode: 'Create', path: 'create' },
  5. { mode: 'Show', path: ':id(\\d+)' },
  6. { mode: 'Edit', path: ':id(\\d+)/edit' }
  7. ]
  8. const children = []
  9. const removedFirstPart = componentPath.split('/')
  10. // console.log('removedFirstPart', removedFirstPart[0])
  11. AllNeededRoutes.forEach(item => {
  12. // Todo : find a way for 'pages/'
  13. children.push({ name: baseRouteName + '.' + item.mode, path: item.path, component: () => import('../pages/' + componentPath.replace(removedFirstPart[0] + '/', '') + '.vue') })
  14. // Even this is not working
  15. // children.push({ name: baseRouteName + '.' + item.mode, path: item.path, component: () => import(removedFirstPart[0] + '/' + componentPath.replace(removedFirstPart[0] + '/', '')) })
  16. })
  17. return {
  18. path,
  19. component: () => import('../pages/Admin/index.vue'),
  20. breadcrumbs,
  21. children
  22. }
  23. }
  24. const entityCrudRouteConfigs = [
  25. {
  26. path: 'users',
  27. baseRouteName: 'Admin.UserManagement',
  28. componentPath: 'pages/Admin/User/UserManagement',
  29. breadcrumbs: { title: 'مدیریت کاربران' }
  30. },
  31. {
  32. path: 'scheduleManagement',
  33. baseRouteName: 'Admin.ScheduleManagement',
  34. componentPath: 'pages/Admin/ScheduleManagement',
  35. breadcrumbs: { title: 'مدیریت ساعت کاری' }
  36. },
  37. {
  38. path: 'permission',
  39. baseRouteName: 'Admin.Permission',
  40. componentPath: 'pages/Admin/User/Permission',
  41. breadcrumbs: { title: 'مدیریت دسترسی ها' }
  42. },
  43. {
  44. path: 'rolesManagement',
  45. baseRouteName: 'Admin.Roles',
  46. componentPath: 'pages/Admin/User/Roles',
  47. breadcrumbs: { title: 'مدیریت نقش ها' }
  48. },
  49. {
  50. path: 'product',
  51. baseRouteName: 'Admin.Product',
  52. componentPath: 'pages/Admin/User/Product',
  53. breadcrumbs: { title: 'محصولات' }
  54. },
  55. {
  56. path: 'content',
  57. baseRouteName: 'Admin.Content',
  58. componentPath: 'pages/Admin/Content/Content',
  59. breadcrumbs: { title: 'محتوا' }
  60. },
  61. {
  62. path: 'sourceManagement',
  63. baseRouteName: 'Admin.SourceManagement',
  64. componentPath: 'pages/Admin/Content/SourceManagement',
  65. breadcrumbs: { title: 'مدیریت منابع' }
  66. },
  67. {
  68. path: 'section',
  69. baseRouteName: 'Admin.Section',
  70. componentPath: 'pages/Admin/Content/Section',
  71. breadcrumbs: { title: 'سکشن محتوا' }
  72. },
  73. {
  74. path: 'attributeManagement',
  75. baseRouteName: 'Admin.AttributeManagement',
  76. componentPath: 'pages/Admin/AttributeManagement',
  77. breadcrumbs: { title: 'مدیریت صفت ها' }
  78. },
  79. {
  80. path: 'attributeSetManagement',
  81. baseRouteName: 'Admin.AttributeSetManagement',
  82. componentPath: 'pages/Admin/AttributeSetManagement',
  83. breadcrumbs: { title: 'مدیریت دسته صفت ها' }
  84. },
  85. {
  86. path: 'attributeValue',
  87. baseRouteName: 'Admin.AttributeValue',
  88. componentPath: 'pages/Admin/AttributeValue',
  89. breadcrumbs: null
  90. },
  91. {
  92. path: 'order',
  93. baseRouteName: 'Admin.Orders',
  94. componentPath: 'pages/Admin/Orders/Order',
  95. breadcrumbs: { title: 'مدیریت سفارشات' }
  96. },
  97. {
  98. path: 'transactions',
  99. baseRouteName: 'Admin.Transaction',
  100. componentPath: 'pages/Admin/Orders/Transaction',
  101. breadcrumbs: { title: 'مدیریت تراکنش ها' }
  102. },
  103. {
  104. path: 'userBon',
  105. baseRouteName: 'Admin.UserBon',
  106. componentPath: 'pages/Admin/Orders/UserBon',
  107. breadcrumbs: { title: 'مدیریت بن کاربران' }
  108. },
  109. {
  110. path: 'smsAdmin',
  111. baseRouteName: 'Admin.SMSAdmin',
  112. componentPath: 'pages/Admin/SMS/SMSAdmin',
  113. breadcrumbs: { title: 'مدیریت پیامک ها' }
  114. },
  115. {
  116. path: 'blockManagement',
  117. baseRouteName: 'Admin.BlockManagement',
  118. componentPath: 'pages/Admin/BlockManagement',
  119. breadcrumbs: { title: 'مدیریت بلاک ها' }
  120. },
  121. {
  122. path: 'registrationManagement',
  123. baseRouteName: 'Admin.RegistrationManagement',
  124. componentPath: 'pages/Admin/RegistrationManagement',
  125. breadcrumbs: { title: 'پنل مدیریت لیست' }
  126. },
  127. {
  128. path: 'ticketDepartment',
  129. baseRouteName: 'Admin.TicketDepartment',
  130. componentPath: 'pages/Admin/TicketDepartment',
  131. breadcrumbs: { title: 'مدیریت گروه تیکت' }
  132. },
  133. {
  134. path: 'slideShowManagement',
  135. baseRouteName: 'Admin.SlideShowManagement',
  136. componentPath: 'pages/Admin/SlideShowManagement',
  137. breadcrumbs: { title: 'مدیریت اسلاید شو صفحه اصلی' }
  138. },
  139. {
  140. path: 'tags',
  141. baseRouteName: 'Admin.Tags',
  142. componentPath: 'pages/Admin/Tags',
  143. breadcrumbs: { title: 'مدیریت تگ ها' }
  144. },
  145. {
  146. path: 'activityLog',
  147. baseRouteName: 'Admin.ActivityLog',
  148. componentPath: 'pages/Admin/ActivityLog',
  149. breadcrumbs: { title: 'لاگ فعالیت ها' }
  150. },
  151. {
  152. path: 'gateway',
  153. baseRouteName: 'Admin.Gateway',
  154. componentPath: 'pages/Admin/Gateway',
  155. breadcrumbs: { title: 'درگاه پرداخت' }
  156. },
  157. {
  158. path: 'coupons',
  159. baseRouteName: 'Admin.Coupons',
  160. componentPath: 'pages/Admin/Coupons',
  161. breadcrumbs: { title: 'مدیریت کپن ها' }
  162. },
  163. {
  164. path: 'liveDescription',
  165. baseRouteName: 'Admin.LiveDescription',
  166. componentPath: 'pages/Admin/LiveDescription',
  167. breadcrumbs: { title: 'توضیحات لحظه ای' }
  168. },
  169. {
  170. path: 'Vouchers',
  171. baseRouteName: 'Admin.Vouchers',
  172. componentPath: 'pages/Admin/Vouchers',
  173. breadcrumbs: { title: 'مدیریت ووچر ها' }
  174. },
  175. {
  176. path: 'teleMarketing',
  177. baseRouteName: 'Admin.TeleMarketing',
  178. componentPath: 'pages/Admin/TeleMarketing',
  179. breadcrumbs: { title: 'تله مارکتینگ' }
  180. },
  181. {
  182. path: 'fixUnknownUsersCity',
  183. baseRouteName: 'Admin.FixUnknownUsersCity',
  184. componentPath: 'pages/Admin/FixUnknownUsersCity',
  185. breadcrumbs: { title: 'اصلاح شهر و استان کاربران' }
  186. },
  187. {
  188. path: 'coupon',
  189. baseRouteName: 'Admin.Coupon',
  190. componentPath: 'pages/Admin/Coupon',
  191. breadcrumbs: { title: 'کوپن ها' }
  192. }
  193. ]
  194. const EntityCrudRoutes = [
  195. ...entityCrudRouteConfigs.map(item => getEntityCrudRouteObject(item.path, item.baseRouteName, item.componentPath, item.breadcrumbs))
  196. ]
  197. export default EntityCrudRoutes