Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
EditMemberParams.php
Go to the documentation of this file.
1<?php
2
4
5use Ajax\JsUtils;
6
13 private $parentId;
14 private $selector;
15 private $event;
16 private $hasButtons;
17 private $hasPopup;
20
21 public function __construct($parentId="",$selector="[data-field]",$event="dblclick",$hasButtons=true,$hasPopup=false,$updateCallback="",$identifierSelector="$(this).closest('tr').attr('data-ajax')"){
22 $this->parentId=$parentId;
23 $this->selector=$selector;
24 $this->event=$event;
25 $this->hasButtons=$hasButtons;
26 $this->hasPopup=$hasPopup;
27 $this->updateCallback=$updateCallback;
28 $this->identifierSelector=$identifierSelector;
29 }
30
31 private function getJsCallbackForEditMember(){
32 if($this->hasPopup){
33 return "$(self).popup({hideOnScroll: false,exclusive: true,delay:{show:50,hide: 5000},closable: false, variation: 'very wide',html: data, hoverable: true,className: {popup: 'ui popup'}}).popup('show');";
34 }else{
35 return "$(self).html(function(i,v){return $(this).data('originalText', v) || '';});";
36 }
37 }
38
42 public function getSelector() {
43 return $this->selector;
44 }
45
49 public function getEvent() {
50 return $this->event;
51 }
52
56 public function getHasButtons() {
57 return $this->hasButtons;
58 }
59
63 public function getHasPopup() {
64 return $this->hasPopup;
65 }
66
70 public function getUpdateCallback() {
72 }
73
77 public function setSelector($selector) {
78 $this->selector = $selector;
79 }
80
84 public function setEvent($event) {
85 $this->event = $event;
86 }
87
91 public function setHasButtons($hasButtons) {
92 $this->hasButtons = $hasButtons;
93 }
94
98 public function setHasPopup($hasPopup) {
99 $this->hasPopup = $hasPopup;
100 }
101
106 $this->updateCallback = $updateCallback;
107 }
111 public function getIdentifierSelector() {
113 }
114
119 $this->identifierSelector = $identifierSelector;
120 }
121
122 public static function dataElement(){
123 return new EditMemberParams("#de", "td[data-field]","dblclick",true,true,"updateMemberDataElement","$(this).closest('table').attr('data-ajax')");
124 }
125
126 public static function dataTable($parentId='#lv'){
127 return new EditMemberParams($parentId);
128 }
129
130 public function compile($baseRoute,JsUtils $jquery,$part=null){
131 $part=(isset($part))?", part: '".$part."'":"";
132 $jsCallback=$this->getJsCallbackForEditMember();
133 $element=null;
134 if(!$this->hasPopup){
135 $element="\$(self)";
136 $before=$jsCallback;
137 $jsCallback="";
138 }else{
139 $before="";
140 }
141 $jquery->postOn($this->event,$this->selector, $baseRoute."/editMember/","{id: ".$this->identifierSelector.",td:$(this).attr('id')".$part."}",$element,["attr"=>"data-field","hasLoader"=>false,"jqueryDone"=>"html","before"=>"$('._memberForm').trigger('endEdit');".$before,"jsCallback"=>$jsCallback,"listenerOn"=>$this->parentId]);
142
143 }
144
145}
146
For using in a CRUDController ModelViewer with getEditMemberParams method.
__construct($parentId="", $selector="[data-field]", $event="dblclick", $hasButtons=true, $hasPopup=false, $updateCallback="", $identifierSelector="$(this).closest('tr').attr('data-ajax')")
compile($baseRoute, JsUtils $jquery, $part=null)