use of com.playshogi.website.gwt.client.place.ProblemsPlace in project playshogi by Tellmarch.
the class LessonsView method showLessonPreview.
private void showLessonPreview(final LessonDetails lesson) {
previewCard.setTitle(lesson.getTitle());
previewDescription.textContent(lesson.getDescription());
difficulty.textContent("Difficulty: ");
for (int i = 1; i <= 5; i++) {
if (i > lesson.getDifficulty()) {
difficulty.add(Icons.ALL.star_border());
} else {
difficulty.add(Icons.ALL.star());
}
}
previewTags.textContent("");
for (String tag : lesson.getTags()) {
previewTags.add(Label.createPrimary(tag).style().setMargin("1em"));
}
if (lesson.getPreviewSfen() != null && !lesson.getPreviewSfen().isEmpty()) {
boardPreview.showPosition(SfenConverter.fromSFEN(lesson.getPreviewSfen()));
boardPreview.setVisible(true);
} else {
boardPreview.setVisible(false);
}
if (lesson.getKifuId() != null) {
String exploreHRef = "#" + historyMapper.getToken(new ViewLessonPlace(lesson.getLessonId(), lesson.getKifuId(), 0));
openButton.attr("href", exploreHRef);
openButton.hidden(false);
} else if (lesson.getProblemCollectionId() != null) {
String exploreHRef = "#" + historyMapper.getToken(new ProblemsPlace(lesson.getProblemCollectionId(), 0, lesson.getLessonId()));
openButton.attr("href", exploreHRef);
openButton.hidden(false);
} else {
openButton.hidden(true);
}
}
use of com.playshogi.website.gwt.client.place.ProblemsPlace in project playshogi by Tellmarch.
the class LessonsTable method getTableConfig.
private TableConfig<LessonDetails> getTableConfig(final AppPlaceHistoryMapper historyMapper) {
TableConfig<LessonDetails> tableConfig = new TableConfig<>();
tableConfig.addColumn(ColumnConfig.<LessonDetails>create("num", "#").styleCell(element -> element.style.setProperty("vertical-align", "top")).textAlign("right").asHeader().setCellRenderer(cell -> TextNode.of(String.valueOf(cell.getTableRow().getIndex() + 1 + PAGE_SIZE * (simplePaginationPlugin.getSimplePagination().activePage() - 1))))).addColumn(ColumnConfig.<LessonDetails>create("id", "id").styleCell(element -> element.style.setProperty("vertical-align", "top")).textAlign("right").asHeader().setCellRenderer(cell -> TextNode.of(cell.getRecord().getLessonId()))).addColumn(ColumnConfig.<LessonDetails>create("status", "Status").styleCell(element -> element.style.setProperty("vertical-align", "top")).textAlign("center").setCellRenderer(cell -> {
if (!cell.getRecord().isHidden()) {
return Style.of(Icons.ALL.check_circle()).setColor(Color.GREEN_DARKEN_3.getHex()).element();
} else {
return Style.of(Icons.ALL.highlight_off()).setColor(Color.RED_DARKEN_3.getHex()).element();
}
})).addColumn(ColumnConfig.<LessonDetails>create("title", "Title").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getTitle()))).addColumn(ColumnConfig.<LessonDetails>create("description", "Description").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getDescription()))).addColumn(ColumnConfig.<LessonDetails>create("parent", "Parent").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getParentLessonId()))).addColumn(ColumnConfig.<LessonDetails>create("kifu", "Kifu").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getKifuId()))).addColumn(ColumnConfig.<LessonDetails>create("problems", "Problem Collection").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getProblemCollectionId()))).addColumn(ColumnConfig.<LessonDetails>create("difficulty", "Difficulty").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> getDifficulty(cell.getRecord())).setSortable(true)).addColumn(ColumnConfig.<LessonDetails>create("author", "Author").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getAuthor())).setSortable(true)).addColumn(ColumnConfig.<LessonDetails>create("tags", "Tags").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
HtmlContentBuilder<HTMLElement> span = Elements.span();
for (String tag : cell.getRecord().getTags()) {
span.add(Badge.create(tag).setBackground(ColorScheme.GREEN.color()).style().setMarginRight("1em").element());
}
return span.element();
})).addColumn(ColumnConfig.<LessonDetails>create("edit", "Edit").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> Button.createPrimary("Edit").addClickListener(evt -> lessonPropertiesForm.showInPopup(cell.getRecord())).element())).addColumn(ColumnConfig.<LessonDetails>create("open", "Open Lesson").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
LessonDetails record = cell.getRecord();
if (record.getKifuId() != null) {
String href = "#" + historyMapper.getToken(new ViewLessonPlace(record.getLessonId(), record.getKifuId(), 0));
return Elements.a(href).add(Button.createPrimary("Open")).element();
} else if (record.getProblemCollectionId() != null) {
String href = "#" + historyMapper.getToken(new ProblemsPlace(record.getProblemCollectionId(), 0));
return Elements.a(href).add(Button.createPrimary("Open")).element();
} else {
return TextNode.of("N/A");
}
}));
return tableConfig;
}
use of com.playshogi.website.gwt.client.place.ProblemsPlace in project playshogi by Tellmarch.
the class ProblemCollectionsTable method getTableConfig.
private TableConfig<ProblemCollectionDetails> getTableConfig(final AppPlaceHistoryMapper historyMapper) {
TableConfig<ProblemCollectionDetails> tableConfig = new TableConfig<>();
tableConfig.addColumn(ColumnConfig.<ProblemCollectionDetails>create("id", "#").styleCell(element -> element.style.setProperty("vertical-align", "top")).textAlign("right").asHeader().setCellRenderer(cell -> TextNode.of(String.valueOf(cell.getTableRow().getIndex() + 1 + PAGE_SIZE * (simplePaginationPlugin.getSimplePagination().activePage() - 1))))).addColumn(ColumnConfig.<ProblemCollectionDetails>create("name", "Name").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getName())).setSortable(true)).addColumn(ColumnConfig.<ProblemCollectionDetails>create("practice", "Practice").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
String href = "#" + historyMapper.getToken(new ProblemsPlace(cell.getRecord().getId(), 0));
return Elements.a(href).add(Button.createSuccess(Icons.ALL.timer()).setContent("Practice / Speedrun")).element();
})).addColumn(ColumnConfig.<ProblemCollectionDetails>create("difficulty", "Difficulty").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> getDifficulty(cell.getRecord())).setSortable(true));
if (!isAuthor) {
tableConfig.addColumn(ColumnConfig.<ProblemCollectionDetails>create("author", "Author").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getAuthor())).setSortable(true));
}
if (isAuthor || canEdit) {
tableConfig.addColumn(ColumnConfig.<ProblemCollectionDetails>create("visibility", "Visibility").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> TextNode.of(cell.getRecord().getVisibility())));
}
tableConfig.addColumn(ColumnConfig.<ProblemCollectionDetails>create("solved", "Solved").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> getSolved(cell.getRecord()))).addColumn(ColumnConfig.<ProblemCollectionDetails>create("besttime", "Personal Best Time").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> getPersonalBest(cell.getRecord())).setSortable(true)).addColumn(ColumnConfig.<ProblemCollectionDetails>create("leaderboard", "Leaderboard").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> getLeaderboard(cell.getRecord())));
if (isAuthor) {
tableConfig.addColumn(ColumnConfig.<ProblemCollectionDetails>create("open", "Open Collection").styleCell(element -> element.style.setProperty("vertical-align", "top")).setCellRenderer(cell -> {
String href = "#" + historyMapper.getToken(new ProblemCollectionPlace(cell.getRecord().getId()));
return Elements.a(href).add(Button.createPrimary("Open")).element();
}));
}
return tableConfig;
}
Aggregations