Skip to content

Commit

Permalink
#225 fixed field deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
qifeng-bai committed Nov 23, 2023
1 parent 0c2264b commit e00334c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,12 @@ class ManageLayersController {
*/
@RequireAdmin
def delete(String id, String action) {
if (fieldService.getFieldById(id, false) == null) {
def field = fieldService.getFieldById(id, false)
if (field) {
def layerId = field.spid
manageLayersService.deleteField(id)
redirect(action: action, id: layerId)
} else {
Map m = manageLayersService.getUpload(id, false)
if (m == null || (!m.containsKey('data_resource_uid') && !m.containsKey('checklist'))) {
manageLayersService.deleteLayer(id)
Expand All @@ -403,11 +408,6 @@ class ManageLayersController {
manageLayersService.deleteChecklist(id)
}
redirect(action: action)
} else {
def layerId = fieldService.getFieldById(id, false).spid
manageLayersService.deleteField(id)

redirect(action: action, id: layerId)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ class ManageLayersService {
String layersDir = spatialConfig.data.dir

//fields
Fields field = fieldService.getFieldById(fieldId)
Fields field = fieldService.getFieldById(fieldId, false)
if (field != null) {

fieldService.delete(fieldId)
Expand Down
9 changes: 2 additions & 7 deletions grails-app/views/manageLayers/field.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,8 @@
edit</g:link>
</td>
<td>
<g:if test="${item.enabled}">
<a onclick="return confirmDelete('${item.id}','${item.name}' );">
<i class="glyphicon glyphicon-remove"></i> </a>
</g:if>
<g:else>
<i class="glyphicon glyphicon-ban-circle" data-toggle="tooltip" data-placement="top" title="You are not allowed to delete a disabled field."></i>
</g:else>
<a onclick="return confirmDelete('${item.id}','${item.name}' );">
<i class="glyphicon glyphicon-remove"></i> </a>
</td>
</tr>
</g:each>
Expand Down
9 changes: 2 additions & 7 deletions grails-app/views/manageLayers/layer.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,8 @@
</g:link>
</td>
<td>
<g:if test="${item.enabled}">
<a onclick="return confirmDelete('${item.id}','${item.name}' );">
<i class="glyphicon glyphicon-remove"></i> </a>
</g:if>
<g:else>
<i class="glyphicon glyphicon-ban-circle" data-toggle="tooltip" data-placement="top" title="You are not allowed to delete a disabled field."></i>
</g:else>
<a onclick="return confirmDelete('${item.id}','${item.name}' );">
<i class="glyphicon glyphicon-remove"></i> </a>
</td>
</tr>
</g:each>
Expand Down
7 changes: 4 additions & 3 deletions grails-app/views/manageLayers/layers.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@
<tbody>
<g:each var="item" in="${layers}">
<tr>
<g:set var="disabledLayer" value="${item.enabled ? '' :'disabled'}" />
<td>${item.dt_added}</td>
<td>${item.id}</td>
<td>${item.name}</td>
<td>${item.displayname}</td>
<td class="${disabledLayer}" >${item.id}</td>
<td class="${disabledLayer}" >${item.name}</td>
<td class="${disabledLayer}" >${item.displayname}</td>
<td>${item.enabled}</td>
<td>
<g:each in="${item.fields}" var="field" status="i">
Expand Down

0 comments on commit e00334c

Please sign in to comment.