forked from Archives/Athou_commafeed
remember expanded state
This commit is contained in:
@@ -30,6 +30,8 @@ public class FeedCategory extends AbstractModel {
|
|||||||
@OneToMany(mappedBy = "category")
|
@OneToMany(mappedBy = "category")
|
||||||
private Set<FeedSubscription> subscriptions;
|
private Set<FeedSubscription> subscriptions;
|
||||||
|
|
||||||
|
private boolean collapsed;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@@ -73,4 +75,12 @@ public class FeedCategory extends AbstractModel {
|
|||||||
this.children = children;
|
this.children = children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCollapsed() {
|
||||||
|
return collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCollapsed(boolean collapsed) {
|
||||||
|
this.collapsed = collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ import com.google.common.collect.Lists;
|
|||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class Category implements Serializable {
|
public class Category implements Serializable {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
private List<Category> children = Lists.newArrayList();
|
private List<Category> children = Lists.newArrayList();
|
||||||
private List<Subscription> feeds = Lists.newArrayList();
|
private List<Subscription> feeds = Lists.newArrayList();
|
||||||
|
private boolean expanded;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
@@ -45,4 +46,11 @@ public class Category implements Serializable {
|
|||||||
this.feeds = feeds;
|
this.feeds = feeds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isExpanded() {
|
||||||
|
return expanded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpanded(boolean expanded) {
|
||||||
|
this.expanded = expanded;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -60,6 +60,20 @@ public class SubscriptionsREST extends AbstractREST {
|
|||||||
return Response.ok(Status.OK).build();
|
return Response.ok(Status.OK).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("collapse")
|
||||||
|
public Response collapse(@QueryParam("id") String id,
|
||||||
|
@QueryParam("collapse") boolean collapse) {
|
||||||
|
Preconditions.checkNotNull(id);
|
||||||
|
if (!"all".equals(id)) {
|
||||||
|
FeedCategory category = feedCategoryService.findById(getUser(),
|
||||||
|
Long.valueOf(id));
|
||||||
|
category.setCollapsed(collapse);
|
||||||
|
feedCategoryService.update(category);
|
||||||
|
}
|
||||||
|
return Response.ok(Status.OK).build();
|
||||||
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("import")
|
@Path("import")
|
||||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||||
@@ -100,6 +114,7 @@ public class SubscriptionsREST extends AbstractREST {
|
|||||||
List<FeedSubscription> subscriptions) {
|
List<FeedSubscription> subscriptions) {
|
||||||
Category category = new Category();
|
Category category = new Category();
|
||||||
category.setId(String.valueOf(id));
|
category.setId(String.valueOf(id));
|
||||||
|
category.setExpanded(true);
|
||||||
|
|
||||||
for (FeedCategory c : categories) {
|
for (FeedCategory c : categories) {
|
||||||
if ((id == null && c.getParent() == null)
|
if ((id == null && c.getParent() == null)
|
||||||
@@ -109,6 +124,7 @@ public class SubscriptionsREST extends AbstractREST {
|
|||||||
subscriptions);
|
subscriptions);
|
||||||
child.setId(String.valueOf(c.getId()));
|
child.setId(String.valueOf(c.getId()));
|
||||||
child.setName(c.getName());
|
child.setName(c.getName());
|
||||||
|
child.setExpanded(!c.isCollapsed());
|
||||||
category.getChildren().add(child);
|
category.getChildren().add(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<li> <input type="checkbox" checked="checked" />
|
<li> <input type="checkbox" ng-model="node.expanded" ng-click="toggleCategory(node)" />
|
||||||
<label ng-click="categoryClick({id: node.id})"
|
<label ng-click="categoryClick({id: node.id})"
|
||||||
ng-class="{selected: (node.id == selectedId && selectedType == 'category')}">{{formatCategoryName({category:node})}}
|
ng-class="{selected: (node.id == selectedId && selectedType == 'category')}">{{formatCategoryName({category:node})}}
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@@ -90,7 +90,15 @@ module.directive('category', function($compile) {
|
|||||||
.unsubscribe(subscription.id);
|
.unsubscribe(subscription.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
$scope.toggleCategory = function(category) {
|
||||||
|
console.log(category.expanded)
|
||||||
|
SubscriptionService.collapse({
|
||||||
|
id : category.id,
|
||||||
|
collapse : !category.expanded
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ module.factory('SubscriptionService', [
|
|||||||
params : {
|
params : {
|
||||||
_method : 'unsubscribe'
|
_method : 'unsubscribe'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
collapse : {
|
||||||
|
method : 'GET',
|
||||||
|
params : {
|
||||||
|
_method : 'collapse'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var s = {};
|
var s = {};
|
||||||
@@ -84,6 +90,7 @@ module.factory('SubscriptionService', [
|
|||||||
id : id
|
id : id
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
s.collapse = res.collapse;
|
||||||
s.init();
|
s.init();
|
||||||
return s;
|
return s;
|
||||||
} ]);
|
} ]);
|
||||||
|
|||||||
Reference in New Issue
Block a user