Changeset 487 for TFP-WebServer/bin/Mods/Xample_MarkersMod
- Timestamp:
- Jun 17, 2024, 5:25:43 PM (5 months ago)
- Location:
- TFP-WebServer/bin/Mods/Xample_MarkersMod
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TFP-WebServer/bin/Mods/Xample_MarkersMod/ModInfo.xml
r485 r487 5 5 <Description value="Allows placing custom markers on the web map" /> 6 6 <Author value="Catalysm and Alloc" /> 7 <Version value=" 22.0.1.0" />7 <Version value="1.1.0.0" /> 8 8 <Website value="" /> 9 9 </xml> -
TFP-WebServer/bin/Mods/Xample_MarkersMod/WebMod/bundle.js
r485 r487 15 15 LayersControl, 16 16 Marker, 17 Tooltip, 17 18 HideBasedOnAuth, 18 19 L … … 45 46 lng: y 46 47 } 47 } );48 }, /*#__PURE__*/React.createElement(Tooltip, null, marker.name)); 48 49 }); 49 50 setMarkers(markerComponents); … … 82 83 formState: { 83 84 errors 84 } 85 }, 86 setValue 85 87 } = useForm(); 86 88 const { … … 91 93 mutate: createMarker 92 94 } = useMutation('createMarker', data => HTTP.post('/api/markers', { 95 name: data.name, 93 96 x: parseInt(data.x, 10), 94 97 y: parseInt(data.y, 10) … … 104 107 mutate: updateMarker 105 108 } = useMutation('updateMarker', data => HTTP.put(`/api/markers/${data.id}`, { 109 name: data.name, 106 110 x: parseInt(data.x, 10), 107 111 y: parseInt(data.y, 10), … … 114 118 method: 'PUT' 115 119 }); 120 const canDeleteRows = checkPermission({ 121 module: 'webapi.Markers', 122 method: 'DELETE' 123 }); 116 124 const columnDef = [{ 117 125 field: 'id', 118 126 filter: 'agTextColumnFilter', 119 checkboxSelection: true, 120 width: 300, 121 flex: 0 127 flex: 1 128 }, { 129 field: 'name', 130 filter: 'agTextColumnFilter', 131 flex: 1 122 132 }, { 123 133 field: 'x', 124 134 filter: 'agNumberColumnFilter', 125 editable: canEditRows, 126 cellEditorPopup: true, 127 width: 50, 128 flex: 0 135 flex: 0.25, 136 sort: 'asc' 129 137 }, { 130 138 field: 'y', 131 139 filter: 'agNumberColumnFilter', 132 editable: canEditRows, 133 cellEditorPopup: true, 134 width: 50, 135 flex: 0 140 flex: 0.25, 141 sort: 'asc' 136 142 }, { 137 143 field: 'icon', 138 144 filter: 'agTextColumnFilter', 139 editable: canEditRows,140 cellEditorPopup: true,141 145 flex: 1 142 146 }]; 143 const CreateMarker = () => { 147 const Form = /*#__PURE__*/React.createElement(TfpForm, { 148 id: "markers-form", 149 error: errors 150 }, /*#__PURE__*/React.createElement(FormElements.StyledFormItem, null, /*#__PURE__*/React.createElement(FormElements.FormLabel, { 151 htmlFor: "input-id" 152 }, "ID"), /*#__PURE__*/React.createElement(FormElements.FormInput, _extends({ 153 key: "id", 154 id: "input-id" 155 }, register('id'), { 156 disabled: true 157 }))), /*#__PURE__*/React.createElement(FormElements.StyledFormItem, null, /*#__PURE__*/React.createElement(FormElements.FormLabel, { 158 htmlFor: "input-name" 159 }, "Name"), /*#__PURE__*/React.createElement(FormElements.FormInput, _extends({ 160 key: "name", 161 id: "input-name" 162 }, register('name')))), /*#__PURE__*/React.createElement(FormElements.StyledFormItem, null, /*#__PURE__*/React.createElement(FormElements.FormLabel, { 163 htmlFor: "input-x" 164 }, "X"), /*#__PURE__*/React.createElement(FormElements.FormInput, _extends({ 165 key: "x", 166 id: "input-x" 167 }, register('x', { 168 required: true 169 })))), /*#__PURE__*/React.createElement(FormElements.StyledFormItem, null, /*#__PURE__*/React.createElement(FormElements.FormLabel, { 170 htmlFor: "input-y" 171 }, "Y"), /*#__PURE__*/React.createElement(FormElements.FormInput, _extends({ 172 key: "y", 173 id: "input-y" 174 }, register('y', { 175 required: true 176 }))))); 177 async function handleCreate(data) { 144 178 if (!checkPermission({ 145 179 module: 'webapi.Markers', 146 180 method: 'POST' 147 181 })) { 148 return null; 149 } 150 return /*#__PURE__*/React.createElement(TfpForm, { 151 id: "markers-form", 152 handleSubmit: handleSubmit(createMarker), 153 error: errors 154 }, /*#__PURE__*/React.createElement(FormElements.StyledFormItem, null, /*#__PURE__*/React.createElement(FormElements.FormLabel, { 155 htmlFor: "input-x" 156 }, "X"), /*#__PURE__*/React.createElement(FormElements.FormInput, _extends({ 157 key: "x", 158 id: "input-x" 159 }, register('x', { 160 required: true 161 })))), /*#__PURE__*/React.createElement(FormElements.StyledFormItem, null, /*#__PURE__*/React.createElement(FormElements.FormLabel, { 162 htmlFor: "input-y" 163 }, "Y"), /*#__PURE__*/React.createElement(FormElements.FormInput, _extends({ 164 key: "y", 165 id: "input-y" 166 }, register('y', { 167 required: true 168 }))))); 169 }; 170 async function cellEdited({ 171 data, 172 newValue, 173 column 174 }) { 182 return; 183 } 184 createMarker(data); 185 } 186 async function handleEdit(data) { 175 187 if (!checkPermission({ 176 188 module: 'webapi.Markers', … … 179 191 return; 180 192 } 181 const changedField = column.colId; 182 updateMarker({ 183 ...data, 184 [changedField]: newValue 185 }); 193 updateMarker(data); 186 194 } 187 195 async function cellDeleted(row) { … … 194 202 deleteMarker(row.id); 195 203 } 204 const setDefaultValues = data => { 205 setValue('id', data.id); 206 setValue('name', data.name); 207 setValue('x', data.x); 208 setValue('y', data.y); 209 }; 196 210 return /*#__PURE__*/React.createElement("div", { 197 211 style: { … … 199 213 height: '80vh' 200 214 } 201 }, /*#__PURE__*/React.createElement( CreateMarker, null), /*#__PURE__*/React.createElement(EditableTable, {215 }, /*#__PURE__*/React.createElement(EditableTable, { 202 216 columnDef: columnDef, 203 217 rowData: data, 204 218 reloadFn: refetch, 205 editRowFn: cellEdited,206 219 deleteRowFn: cellDeleted, 207 height: '90%' 220 canDeleteRows: canDeleteRows, 221 height: '90%', 222 editRowFn: handleSubmit(handleEdit), 223 editForm: Form, 224 setDefaultValues: setDefaultValues, 225 canEditRows: canEditRows, 226 canCreateRows: canEditRows, 227 createRowFn: handleSubmit(handleCreate) 208 228 })); 209 229 }
Note:
See TracChangeset
for help on using the changeset viewer.