Skip to content

Commit

Permalink
SSP-3066 More Fixes for Map Template update
Browse files Browse the repository at this point in the history
  • Loading branch information
scody committed Jul 2, 2015
1 parent 989a9d0 commit 78e4109
Show file tree
Hide file tree
Showing 12 changed files with 336 additions and 220 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/jasig/ssp/dao/TemplateDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public PagingWrapper<Template> getAll(
{
criteria.add(Restrictions.eq("departmentCode", searchTO.getDepartmentCode()));
}
if(!StringUtils.isEmpty(searchTO.getName()))
{
criteria.add(Restrictions.like("name", "%" + searchTO.getName() + "%"));
}
return processCriteriaWithStatusSortingAndPaging(criteria,
sNp);
}
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/org/jasig/ssp/transferobject/TemplateSearchTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@ public class TemplateSearchTO {
private String divisionCode;
private String programCode;
private String departmentCode;
private String name;

public TemplateSearchTO() {

}

public TemplateSearchTO(MapTemplateVisibility visibility, ObjectStatus objectStatus,
String divisionCode, String programCode, String departmentCode) {
String divisionCode, String programCode, String departmentCode, String name) {
super();
this.visibility = visibility;
this.objectStatus = objectStatus;
this.divisionCode = divisionCode;
this.programCode = programCode;
this.departmentCode = departmentCode;
this.name = name;
}



public MapTemplateVisibility getVisibility() {
return visibility;
}
Expand Down Expand Up @@ -83,6 +87,14 @@ public void setDepartmentCode(String departmentCode) {
this.departmentCode = departmentCode;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Boolean visibilityAll(){
if(visibility == null)
return true;
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/jasig/ssp/web/api/TemplateController.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ PagedResponse<TemplateTO> get(
final @RequestParam(required = false) ObjectStatus objectStatus,
final @RequestParam(required = false) String divisionCode,
final @RequestParam(required = false) String programCode,
final @RequestParam(required = false) String departmentCode) throws ObjectNotFoundException,
final @RequestParam(required = false) String departmentCode,
final @RequestParam(required = false) String name) throws ObjectNotFoundException,
ValidationException {

TemplateSearchTO searchTO = new TemplateSearchTO(visibility, objectStatus,
divisionCode, programCode, departmentCode);
divisionCode, programCode, departmentCode, name);
validateAccessForGet(searchTO);
final PagingWrapper<Template> data = getService().getAll(
SortingAndPaging.createForSingleSortWithPaging(
Expand Down Expand Up @@ -190,11 +191,12 @@ PagedResponse<TemplateLiteTO> getSummary(
final @RequestParam(required = false) ObjectStatus objectStatus,
final @RequestParam(required = false) String divisionCode,
final @RequestParam(required = false) String programCode,
final @RequestParam(required = false) String departmentCode) throws ObjectNotFoundException,
final @RequestParam(required = false) String departmentCode,
final @RequestParam(required = false) String name) throws ObjectNotFoundException,
ValidationException {

TemplateSearchTO searchTO = new TemplateSearchTO(visibility, objectStatus,
divisionCode, programCode, departmentCode);
divisionCode, programCode, departmentCode, name);

validateAccessForGet(searchTO);
final PagingWrapper<Template> data = getService().getAll(
Expand Down
9 changes: 9 additions & 0 deletions src/main/webapp/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,15 @@ Ext.onReady(function(){
},
singleton: true
},
planTemplatesStore: {
fn: function(){
return Ext.create('Ssp.store.PlanTemplates', {
storeId: 'planTemplatesSummaryStore',
extraParams: {sort: "name", status: "ALL", limit: "-1"}
});
},
singleton: true
},
employmentShiftsStore: 'Ssp.store.reference.EmploymentShifts',
ethnicitiesStore: 'Ssp.store.reference.Ethnicities',
ethnicitiesAllStore: {
Expand Down
220 changes: 220 additions & 0 deletions src/main/webapp/app/controller/admin/map/LoadTemplateViewController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*
* Licensed to Apereo under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Apereo licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a
* copy of the License at the following location:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
Ext.define('Ssp.controller.admin.map.LoadTemplateViewController', {
extend: 'Deft.mvc.ViewController',
mixins: [ 'Deft.mixin.Injectable' ],
inject:{
appEventsController: 'appEventsController',
formUtils: 'formRendererUtils',
currentMapPlan: 'currentMapPlan',
store: 'planTemplatesSummaryStore',
personLite: 'personLite',
apiProperties: 'apiProperties',
mapPlanService:'mapPlanService',
programsStore: 'programsStore',
departmentsStore: 'departmentsStore',
mapEventUtils: 'mapEventUtils',
divisionsStore: 'divisionsStore'
},

control: {

'name': {
selector: '#templateNameFilter',
listeners: {
keyup: 'ontemplateNameKeyUp'
}
},
'program': {
selector: '#program',
listeners: {
select: 'onProgramSelect'
}
},
'department':{
selector: '#department',
hidden: false,
listeners: {
select: 'onDepartmentSelect'
}
},
'division':{
selector: '#division',
listeners: {
select: 'onDivisionSelect'
}
},
'programCancel':{
selector: '#programCancel',
hidden: true,
listeners: {
click: 'onProgramCancelClick'
}
},
'departmentCancel':{
selector: '#departmentCancel',
hidden: false,
listeners: {
click: 'onDepartmentCancelClick'
}
},
'divisionCancel':{
selector: '#divisionCancel',
listeners: {
click: 'onDivisionCancelClick'
}
},
'objectStatusFilter':{
selector: '#objectStatusFilter',
hidden: false,
listeners: {
select: 'onObjectStatusFilterSelect'
}
},
view: {
show: 'onShow'
},

},

init: function() {
var me=this;
//me.resetForm();
if(me.programsStore.getTotalCount() < 1)
me.programsStore.load();
if(me.departmentsStore.getTotalCount() < 1)
me.departmentsStore.load();
if(me.divisionsStore.getTotalCount() < 1)
me.divisionsStore.load();
me.store.addListener("load", me.onStoreLoaded, me);
return me.callParent(arguments);
},

loadTemplates: function() {
var me = this;
me.getView().setLoading(true);
me.store.load();
me.store.filter([
{
property: 'objectStatus',
value: 'ACTIVE'
}
]);
// callback registered in init()
},

onStoreLoaded: function(){
var me = this;
me.store.sort();
me.getView().setLoading(false);
},

onShow: function() {
// do this on show rather than init b/c this component isn't destroyed
// when dismissed, but we need to make sure you see all the latest
// Template changes whenever we do display this component. The easiest
// way to do that is to just hit the store/server again every time the
// view fires its show event
var me = this;
me.loadTemplates();
},
resetForm: function() {
var me = this;
me.getView().query("form")[0].getForm().reset();
},

onProgramSelect: function(){
var me=this;
me.handleSelect(me);
var params = {};
me.setParam(params, me.getProgram(), "programCode");
},

onProgramCancelClick: function(button){
var me=this;
me.getProgram().setValue("");
me.handleSelect(me);
},

onDepartmentSelect: function(){
var me=this;
me.handleSelect(me);
},

onDepartmentCancelClick: function(button){
var me=this;
me.getDepartment().setValue("");
me.handleSelect(me);
},

onDivisionSelect: function(){
var me=this;
me.handleSelect(me);
},

onDivisionCancelClick: function(button){
var me=this;
me.getDivision().setValue("");
me.handleSelect(me);
},

ontemplateNameKeyUp: function(){
var me=this;
me.handleSelect(me);
},

handleSelect: function(mte){
var grid = Ext.getCmp("templatePanel");
var params = {};
var me = this;
me.setParam(params, Ext.getCmp('program'), 'programCode');
me.setParam(params, Ext.getCmp('department'), 'departmentCode');
me.setParam(params, Ext.getCmp('division'), 'divisionCode');
me.setParam(params, Ext.getCmp('templateNameFilter'), 'name');
params["objectStatus"] = "ALL"; //Object status and object type filtered client side.
grid.store.on('load', me.onLoadComplete, this, {single: true});
grid.store.load({params: params});
},

onLoadComplete: function(){
var me = this;
me.onObjectStatusFilterSelect();
},
setParam: function(params, field, fieldName){
if(field.getValue() && field.getValue().length > 0)
params[fieldName] = field.getValue();
},
onObjectStatusFilterSelect:function(){
var me = this;
var grid = Ext.getCmp("templatePanel");
var objectStatus = Ext.getCmp('objectStatusFilter').getRawValue();
grid.store.clearFilter(false);
if(objectStatus!='ALL'){
grid.store.filter('objectStatus', Ext.getCmp('objectStatusFilter').getRawValue());
}
},

destroy:function(){
var me=this;
me.store.clearFilter(false);
me.store.removeListener("load", me.onStoreLoaded, me);
return me.callParent( arguments );
}

});
Loading

0 comments on commit 78e4109

Please sign in to comment.