github.com/erda-project/erda-infra@v1.0.9/providers/component-protocol/components/table/operation.go (about) 1 // Copyright (c) 2021 Terminus, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package table 16 17 import ( 18 "github.com/erda-project/erda-infra/providers/component-protocol/components/commodel" 19 "github.com/erda-project/erda-infra/providers/component-protocol/cptype" 20 ) 21 22 // table-level 23 type ( 24 // OpTableChangePage includes std op and server&client data. 25 OpTableChangePage struct { 26 cptype.Operation 27 ServerData OpTableChangePageServerData `json:"serverData,omitempty"` 28 ClientData OpTableChangePageClientData `json:"clientData,omitempty"` 29 } 30 // OpTableChangePageServerData . 31 OpTableChangePageServerData struct { 32 } 33 // OpTableChangePageClientData . 34 OpTableChangePageClientData struct { 35 PageNo uint64 `json:"pageNo"` 36 PageSize uint64 `json:"pageSize"` 37 } 38 ) 39 40 // OpKey . 41 func (o OpTableChangePage) OpKey() cptype.OperationKey { return "changePage" } 42 43 type ( 44 // OpTableChangeSort . 45 OpTableChangeSort struct { 46 cptype.Operation 47 ServerData OpTableChangePageServerData `json:"serverData,omitempty"` 48 ClientData OpTableChangeSortClientData `json:"clientData,omitempty"` 49 } 50 // OpTableChangeSortServerData . 51 OpTableChangeSortServerData struct { 52 } 53 // OpTableChangeSortClientData . 54 OpTableChangeSortClientData struct { 55 DataRef *Column `json:"dataRef,omitempty"` 56 } 57 ) 58 59 // OpKey . 60 func (o OpTableChangeSort) OpKey() cptype.OperationKey { 61 return "changeSort" 62 } 63 64 type ( 65 // OpBatchRowsHandle . 66 OpBatchRowsHandle struct { 67 cptype.Operation 68 ServerData OpTableChangePageServerData `json:"serverData,omitempty"` 69 ClientData OpBatchRowsHandleClientData `json:"clientData,omitempty"` 70 } 71 // OpBatchRowsHandleServerData . 72 OpBatchRowsHandleServerData struct { 73 Options []OpBatchRowsHandleOption `json:"options,omitempty"` 74 } 75 // OpBatchRowsHandleOption . 76 OpBatchRowsHandleOption struct { 77 ID string `json:"id,omitempty"` 78 Text string `json:"text,omitempty"` 79 Icon *commodel.Icon `json:"icon,omitempty"` 80 AllowedRowIDs []string `json:"allowedRowIDs,omitempty"` 81 ForbiddenRowIDs []string `json:"forbiddenRowIDs,omitempty"` 82 } 83 // OpBatchRowsHandleClientData . 84 OpBatchRowsHandleClientData struct { 85 DataRef *OpBatchRowsHandleOption `json:"dataRef,omitempty"` 86 SelectedOptionID string `json:"selectedOptionID,omitempty"` 87 SelectedRowIDs []string `json:"selectedRowIDs,omitempty"` 88 } 89 ) 90 91 // OpKey . 92 func (o OpBatchRowsHandle) OpKey() cptype.OperationKey { 93 return "batchRowsHandle" 94 } 95 96 // row-level 97 type ( 98 // OpRowSelect . 99 OpRowSelect struct { 100 cptype.Operation 101 ServerData OpRowSelectServerData `json:"serverData,omitempty"` 102 ClientData OpRowSelectClientData `json:"clientData,omitempty"` 103 } 104 // OpRowSelectServerData . 105 OpRowSelectServerData struct { 106 } 107 // OpRowSelectClientData . 108 OpRowSelectClientData struct { 109 DataRef *Row `json:"dataRef,omitempty"` 110 } 111 ) 112 113 // OpKey . 114 func (o OpRowSelect) OpKey() cptype.OperationKey { 115 return "rowSelect" 116 } 117 118 type ( 119 // OpRowAdd . 120 OpRowAdd struct { 121 cptype.Operation 122 ServerData OpRowAddServerData `json:"serverData,omitempty"` 123 ClientData OpRowAddClientData `json:"clientData,omitempty"` 124 } 125 // OpRowAddServerData . 126 OpRowAddServerData struct { 127 } 128 // OpRowAddClientData . 129 OpRowAddClientData struct { 130 LastRowID string `json:"lastRowID,omitempty"` 131 NextRowID string `json:"nextRowID,omitempty"` 132 NewRow *Row `json:"newRow,omitempty"` 133 } 134 ) 135 136 // OpKey . 137 func (o OpRowAdd) OpKey() cptype.OperationKey { 138 return "rowAdd" 139 } 140 141 type ( 142 // OpRowEdit . 143 OpRowEdit struct { 144 cptype.Operation 145 ServerData OpRowEditServerData `json:"serverData,omitempty"` 146 ClientData OpRowEditClientData `json:"clientData,omitempty"` 147 } 148 // OpRowEditServerData . 149 OpRowEditServerData struct { 150 } 151 // OpRowEditClientData . 152 OpRowEditClientData struct { 153 DataRef *Row `json:"dataRef,omitempty"` 154 NewRow *Row `json:"newRow,omitempty"` 155 } 156 ) 157 158 // OpKey . 159 func (o OpRowEdit) OpKey() cptype.OperationKey { 160 return "rowEdit" 161 } 162 163 type ( 164 // OpRowDelete . 165 OpRowDelete struct { 166 cptype.Operation 167 ServerData OpRowDeleteServerData `json:"serverData,omitempty"` 168 ClientData OpRowDeleteClientData `json:"clientData,omitempty"` 169 } 170 // OpRowDeleteServerData . 171 OpRowDeleteServerData struct { 172 } 173 // OpRowDeleteClientData . 174 OpRowDeleteClientData struct { 175 DataRef *Row `json:"dataRef,omitempty"` 176 } 177 ) 178 179 // OpKey . 180 func (o OpRowDelete) OpKey() cptype.OperationKey { 181 return "rowDelete" 182 } 183 184 // cell-level