Skip to content

Commit df25cd5

Browse files
committed
item active format
1 parent c50bd49 commit df25cd5

13 files changed

Lines changed: 81 additions & 19 deletions

File tree

pegr/grails-app/controllers/pegr/AntibodyController.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class AntibodyController {
1111
}
1212

1313
def list(Integer max) {
14-
params.max = Math.min(max ?: 15, 100)
14+
params.max = Math.min(max ?: 50, 100)
1515
def category = ItemTypeCategory.findBySuperCategory(ItemTypeSuperCategory.ANTIBODY)
1616
def orderLink = utilityService.getInventoryExternalLink()
1717
def itemTypes = itemService.getCategorizedItemTypes()

pegr/grails-app/controllers/pegr/CellSourceController.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class CellSourceController {
3535
item {
3636
eq "active", false
3737
}
38+
} else if (params.active == 'noBarcode') {
39+
isNull "item"
3840
}
3941
}
4042
}

pegr/grails-app/controllers/pegr/ItemController.groovy

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,27 @@ class ItemController {
269269
return
270270
}
271271

272+
def updateActiveAjax(Long itemId, boolean active) {
273+
print(active)
274+
def item = Item.get(itemId)
275+
item.active = active
276+
itemService.save(item)
277+
def label
278+
switch (active) {
279+
case true:
280+
label = "label label-success"
281+
break
282+
case false:
283+
label = "label label-danger"
284+
break
285+
default:
286+
label = "label label-warning"
287+
}
288+
def result = [active: active, label: label] as JSON
289+
render result
290+
return
291+
}
292+
272293
def search(String str) {
273294
def c = Item.createCriteria()
274295
def listParams = [

pegr/grails-app/views/antibody/list.gsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<td>${object?.igType}</td>
4242
<td>${object?.item?.barcode}</td>
4343
<td>${object?.item?.location}</td>
44-
<td>${object?.item?.active}</td>
44+
<td><g:if test="${object?.item?.active}">ACTIVE</g:if><g:elseif test="${object?.item?.active != null}">INACTIVE</g:elseif></td>
4545
</tr>
4646
</g:each>
4747
</tbody>

pegr/grails-app/views/antibody/show.gsp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<div class="row">
1919
<div class="col-sm-6">
2020
<ul>
21-
<g:render template="/item/status" model="[item: antibody.item]"></g:render>
22-
<li>Active: ${antibody.item.active}</li>
21+
<li><g:render template="/item/active" model="[item: antibody.item]"></g:render></li>
22+
<li><g:render template="/item/status" model="[item: antibody.item]"></g:render></li>
2323
<g:if test="${antibody.item?.name}">
2424
<li>Name: ${antibody.item.name}</li>
2525
</g:if>

pegr/grails-app/views/cellSource/list.gsp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<td class="barcode item"><span class="value">${cellSource.item?.barcode}</span></td>
4747
<td class="type item"><span class="value">${cellSource.item?.type}</span></td>
4848
<td class="location item"><span class="value">${cellSource.item?.location}</span></td>
49-
<td>${cellSource.item?.active}</td>
49+
<td><g:if test="${cellSource.item?.active}">ACTIVE</g:if><g:elseif test="${cellSource.item?.active != null}">INACTIVE</g:elseif></td>
5050
</tr>
5151
</g:each>
5252
</tbody>
@@ -63,6 +63,9 @@
6363
<div class="form-group">
6464
<input type="radio" name="active" value="inactive" <g:if test="${active=='inactive'}">checked</g:if>> Inactive items
6565
</div>
66+
<div class="form-group">
67+
<input type="radio" name="active" value="noBarcode" <g:if test="${active=='noBarcode'}">checked</g:if>> No barcode
68+
</div>
6669
<g:submitButton class="btn btn-primary" name="submit" value="Filter"></g:submitButton>
6770
<button onclick="$('input:radio').prop('checked', false);" class="btn btn-default">Clear</button>
6871
</g:form>

pegr/grails-app/views/cellSource/show.gsp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
<div class="row">
2424
<div class="col-sm-6">
2525
<ul>
26-
<g:render template="/item/status" model="[item: cellSource.item]"></g:render>
27-
<li>Active: ${cellSource.item?.active}</li>
26+
<li><g:render template="/item/active" model="[item: cellSource.item]"></g:render></li>
27+
<li><g:render template="/item/status" model="[item: cellSource.item]"></g:render></li>
2828
<g:if test="${cellSource.item?.name}">
2929
<li>Name: ${cellSource.item?.name}</li>
3030
</g:if>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Active: <g:if test="${item?.active}"><span id="item-active-show" class="label label-success">ACTIVE</span></g:if>
2+
<g:else><span id="item-active-show" class="label label-danger">INACTIVE</span></g:else>
3+
<span id="item-active-select" style="display:none">
4+
<select name="active">
5+
<option value="true">ACTIVE</option>
6+
<option value="false">INACTIVE</option>
7+
</select>
8+
<button id="item-active-save" class="btn btn-primary">Save</button>
9+
<button id="item-active-cancel" class="btn btn-default">Cancel</button>
10+
</span>
11+
12+
<script>
13+
$("#item-active-show").click(function(){
14+
$("#item-active-show").hide();
15+
$("#item-active-select").show();
16+
});
17+
18+
$("#item-active-save").click(function(){
19+
var active = $("#item-active-select option:selected").val();
20+
21+
$.ajax({ url: "/pegr/item/updateActiveAjax?itemId=${item.id}&active=" + active,
22+
success: function(result) {
23+
if (result.active) {
24+
$("#item-active-show").text('ACTIVE');
25+
} else {
26+
$("#item-active-show").text('INACTIVE');
27+
}
28+
29+
$("#item-active-show").removeClass();
30+
$("#item-active-show").addClass(result.label);
31+
$("#item-active-select").val(result.active);
32+
$("#item-active-show").show();
33+
$("#item-active-select").hide();
34+
}
35+
});
36+
});
37+
38+
$("#item-active-cancel").click(function(){
39+
$("#item-active-show").show();
40+
var active = $("#item-active-show").text();
41+
$("#item-active-select").val(active);
42+
$("#item-active-select").hide();
43+
});
44+
</script>

pegr/grails-app/views/item/_form.gsp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
<%@ page import="pegr.Item" %>
2-
<div class=" ${hasErrors(bean: item, field: 'active', 'error')} ">
3-
<label>Active</label>
4-
<g:formatBoolean name="active" value="${item?.active}"/>
5-
</div>
62

73
<div class=" ${hasErrors(bean: item, field: 'name', 'error')} ">
84
<label>Name</label>

pegr/grails-app/views/item/_formWithBarcode.gsp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
<div class="row">
22
<div class="col-sm-6 fields">
3-
<div class=" ${hasErrors(bean: item, field: 'active', 'error')} ">
4-
<label>Active</label>
5-
<g:textField name="active" value="${item?.active}"/>
6-
</div>
73
<div class=" ${hasErrors(bean: item, field: 'name', 'error')} ">
84
<label>Name</label>
95
<g:textField name="name" value="${item?.name}"/>

0 commit comments

Comments
 (0)