remember expanded state

This commit is contained in:
Jeremie Panzer
2013-03-28 10:39:03 +01:00
parent e0925e8c50
commit 78bfc4424f
6 changed files with 52 additions and 3 deletions

View File

@@ -30,6 +30,8 @@ public class FeedCategory extends AbstractModel {
@OneToMany(mappedBy = "category")
private Set<FeedSubscription> subscriptions;
private boolean collapsed;
public String getName() {
return name;
}
@@ -73,4 +75,12 @@ public class FeedCategory extends AbstractModel {
this.children = children;
}
public boolean isCollapsed() {
return collapsed;
}
public void setCollapsed(boolean collapsed) {
this.collapsed = collapsed;
}
}

View File

@@ -7,11 +7,12 @@ import com.google.common.collect.Lists;
@SuppressWarnings("serial")
public class Category implements Serializable {
private String id;
private String name;
private List<Category> children = Lists.newArrayList();
private List<Subscription> feeds = Lists.newArrayList();
private boolean expanded;
public String getId() {
return id;
@@ -45,4 +46,11 @@ public class Category implements Serializable {
this.feeds = feeds;
}
public boolean isExpanded() {
return expanded;
}
public void setExpanded(boolean expanded) {
this.expanded = expanded;
}
}

View File

@@ -60,6 +60,20 @@ public class SubscriptionsREST extends AbstractREST {
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
@Path("import")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@@ -100,6 +114,7 @@ public class SubscriptionsREST extends AbstractREST {
List<FeedSubscription> subscriptions) {
Category category = new Category();
category.setId(String.valueOf(id));
category.setExpanded(true);
for (FeedCategory c : categories) {
if ((id == null && c.getParent() == null)
@@ -109,6 +124,7 @@ public class SubscriptionsREST extends AbstractREST {
subscriptions);
child.setId(String.valueOf(c.getId()));
child.setName(c.getName());
child.setExpanded(!c.isCollapsed());
category.getChildren().add(child);
}
}