card.html.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. namespace zin;
  3. $cards = array();
  4. foreach($flows as $flow)
  5. {
  6. $btnGroup = array();
  7. $actionItems = array();
  8. $canEdit = $this->workflow->isClickable(null, 'edit');
  9. $canCopy = $this->workflow->isClickable($flow, 'copy');
  10. $canDelete = $this->workflow->isClickable($flow, 'delete');
  11. $canUpgrade = $this->workflow->isClickable($flow, 'upgrade');
  12. $canRelease = $this->workflow->isClickable($flow, 'release');
  13. $canDeactivate = $this->workflow->isClickable($flow, 'deactivate');
  14. $canActivate = $this->workflow->isClickable($flow, 'activate');
  15. $canDesignUI = $this->workflow->isClickable($flow, 'ui');
  16. $canBrowseField = $flow->buildin && commonModel::hasPriv('workflowfield', 'browse');
  17. $canPreview = !$flow->buildin && $flow->status == 'normal' && commonModel::hasPriv($flow->module, 'browse');
  18. $labelClass = 'gray';
  19. if($flow->status == 'normal') $labelClass = 'success';
  20. if($flow->status == 'wait') $labelClass = 'warning';
  21. if($canEdit) $actionItems[] = array
  22. (
  23. 'text' => $lang->edit,
  24. 'url' => inlink('edit', "id=$flow->id"),
  25. 'data-toggle' => 'modal',
  26. 'data-size' => 'sm'
  27. );
  28. if($canCopy) $actionItems[] = array
  29. (
  30. 'text' => $lang->workflow->copyFlow,
  31. 'url' => inlink('copy', "id=$flow->id"),
  32. 'data-toggle' => 'modal',
  33. 'data-size' => 'sm'
  34. );
  35. if($canDelete) $actionItems[] = array
  36. (
  37. 'text' => $lang->delete,
  38. 'url' => inlink('delete', "id=$flow->id"),
  39. 'data-confirm' => array('message' => array('html' => $lang->workflow->tips->deleteConfirm), 'icon' => 'icon-exclamation-sign', 'iconClass' => 'warning-pale rounded-full icon-2x'),
  40. 'innerClass' => 'ajax-submit'
  41. );
  42. if(!empty($flow->app) && in_array($flow->app, array('scrum', 'waterfall'))) $flow->app = 'project';
  43. if($canPreview) $btnGroup[] = btn(
  44. setClass('btn ghost btn-guest ml-2'),
  45. $lang->workflow->preview,
  46. set::url(createLink($flow->module, 'browse', "mode=browse") . "#app=$flow->app")
  47. );
  48. if($canDesignUI) $btnGroup[] = btn(
  49. setClass('btn primary btn-default ml-2'),
  50. $lang->workflow->design,
  51. set::url(inlink('ui', "module=$flow->module"))
  52. );
  53. if($canBrowseField) $btnGroup[] = btn(
  54. setClass('btn primary btn-default ml-2'),
  55. $lang->workflow->design,
  56. set::url(createLink('workflowfield', 'browse', "module=$flow->module"))
  57. );
  58. if($canRelease) $btnGroup[] = btn(
  59. setClass('btn secondary btn-default ml-2'),
  60. $lang->workflow->release,
  61. set::url(inlink('release', "id=$flow->id")),
  62. setData(['toggle' => 'modal', 'size' => 'sm'])
  63. );
  64. if($canDeactivate) $btnGroup[] = btn(
  65. setClass('btn secondary btn-default ml-2'),
  66. $lang->workflow->deactivate,
  67. set::url(inlink('deactivate', "id=$flow->id")),
  68. $flow->belong ? set('data-confirm', $lang->workflow->tips->syncDeactivate) : null
  69. );
  70. if($canActivate) $btnGroup[] = btn(
  71. setClass('btn secondary btn-default ml-2'),
  72. $lang->workflow->activate,
  73. set::url($flow->belong ? 'javascript:activate(' . $flow->id . ')' : $this->createLink('workflow', 'activate', "id={$flow->id}&type=all"))
  74. );
  75. $cards[] = div
  76. (
  77. setClass('col flex-none w-1/4'),
  78. div
  79. (
  80. setClass('border py-2 pl-4 ml-4 mt-4'),
  81. div
  82. (
  83. setClass('flex justify-between items-center'),
  84. div
  85. (
  86. setClass('name ml-2'),
  87. h::strong($flow->name),
  88. $flow->buildin ? span(setClass('text-danger font-bold'), " [{$lang->workflow->buildin}]") : ''
  89. ),
  90. div
  91. (
  92. $actionItems ? dropdown
  93. (
  94. set::caret(false),
  95. btn
  96. (
  97. setClass('ghost square mr-2 open-url not-open-url'),
  98. set::icon('ellipsis-v')
  99. ),
  100. set::items($actionItems)
  101. ) : null
  102. )
  103. ),
  104. div
  105. (
  106. set::className('h-20 ml-2 mt-2 overflow-hidden'),
  107. div($lang->workflow->app, span(setClass('text-primary ml-1'), zget($apps, $flow->app, $flow->name))),
  108. div(setClass('break-all text-gray-400 mt-1'), html(nl2br($flow->desc)))
  109. ),
  110. div
  111. (
  112. setClass('flex items-center mb-2'),
  113. div
  114. (
  115. setClass('cell flex items-center ml-2'),
  116. span(setClass("label capitalize $labelClass"), zget($lang->workflow->statusList, $flow->status))
  117. ),
  118. div
  119. (
  120. setClass('cell flex-1 text-right mr-4 btnGroup'),
  121. setStyle('visibility', 'hidden'),
  122. $btnGroup
  123. )
  124. )
  125. )
  126. );
  127. }
  128. panel
  129. (
  130. setID('cards'),
  131. setClass('row cell canvas mb-4'),
  132. set::bodyClass('w-full'),
  133. div
  134. (
  135. setClass('flex flex-wrap'),
  136. $cards
  137. ),
  138. div(set::className('table-footer'), setKey('pager'), pager(set(usePager()), set::className('pull-right')))
  139. );