Search in sources :

Example 1 with ProblemsPlace

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);
    }
}
Also used : ViewLessonPlace(com.playshogi.website.gwt.client.place.ViewLessonPlace) ProblemsPlace(com.playshogi.website.gwt.client.place.ProblemsPlace)

Example 2 with ProblemsPlace

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;
}
Also used : Icons(org.dominokit.domino.ui.icons.Icons) ElementWidget(com.playshogi.website.gwt.client.util.ElementWidget) ColumnConfig(org.dominokit.domino.ui.datatable.ColumnConfig) RecordsSorter(org.dominokit.domino.ui.datatable.store.RecordsSorter) ASC(org.dominokit.domino.ui.datatable.plugins.SortDirection.ASC) UsfFormat(com.playshogi.library.shogi.models.formats.usf.UsfFormat) Badge(org.dominokit.domino.ui.badges.Badge) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) Elements(org.jboss.elemento.Elements) ViewLessonPlace(com.playshogi.website.gwt.client.place.ViewLessonPlace) Column(org.dominokit.domino.ui.grid.Column) Style(org.dominokit.domino.ui.style.Style) KifuService(com.playshogi.website.gwt.shared.services.KifuService) Elements.h(org.jboss.elemento.Elements.h) GWT(com.google.gwt.core.client.GWT) AppPlaceHistoryMapper(com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper) ProblemsPlace(com.playshogi.website.gwt.client.place.ProblemsPlace) DataTable(org.dominokit.domino.ui.datatable.DataTable) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) HTMLElement(elemental2.dom.HTMLElement) TextHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.TextHeaderFilter) Elements.div(org.jboss.elemento.Elements.div) SelectHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.SelectHeaderFilter) Row(org.dominokit.domino.ui.grid.Row) Window(com.google.gwt.user.client.Window) KifuServiceAsync(com.playshogi.website.gwt.shared.services.KifuServiceAsync) SelectOption(org.dominokit.domino.ui.forms.SelectOption) TextNode(org.dominokit.domino.ui.utils.TextNode) org.dominokit.domino.ui.datatable.plugins(org.dominokit.domino.ui.datatable.plugins) LessonDetails(com.playshogi.website.gwt.shared.models.LessonDetails) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) ColorScheme(org.dominokit.domino.ui.style.ColorScheme) EventBus(com.google.web.bindery.event.shared.EventBus) SessionInformation(com.playshogi.website.gwt.client.SessionInformation) GamePreview(com.playshogi.website.gwt.client.widget.board.GamePreview) BooleanHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.BooleanHeaderFilter) LessonPropertiesForm(com.playshogi.website.gwt.client.widget.collections.LessonPropertiesForm) Widget(com.google.gwt.user.client.ui.Widget) List(java.util.List) SfenConverter(com.playshogi.library.shogi.models.formats.sfen.SfenConverter) Color(org.dominokit.domino.ui.style.Color) HTMLDivElement(elemental2.dom.HTMLDivElement) Node(elemental2.dom.Node) Row_12(org.dominokit.domino.ui.grid.Row_12) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) Comparator(java.util.Comparator) TagsElement(com.playshogi.website.gwt.client.widget.problems.TagsElement) Button(org.dominokit.domino.ui.button.Button) ViewLessonPlace(com.playshogi.website.gwt.client.place.ViewLessonPlace) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) ProblemsPlace(com.playshogi.website.gwt.client.place.ProblemsPlace) LessonDetails(com.playshogi.website.gwt.shared.models.LessonDetails)

Example 3 with ProblemsPlace

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;
}
Also used : DeleteProblemCollectionEvent(com.playshogi.website.gwt.client.events.collections.DeleteProblemCollectionEvent) Icons(org.dominokit.domino.ui.icons.Icons) ColumnConfig(org.dominokit.domino.ui.datatable.ColumnConfig) RecordsSorter(org.dominokit.domino.ui.datatable.store.RecordsSorter) ASC(org.dominokit.domino.ui.datatable.plugins.SortDirection.ASC) LocalListDataStore(org.dominokit.domino.ui.datatable.store.LocalListDataStore) Elements(org.jboss.elemento.Elements) Column(org.dominokit.domino.ui.grid.Column) GWT(com.google.gwt.core.client.GWT) AppPlaceHistoryMapper(com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper) ProblemsPlace(com.playshogi.website.gwt.client.place.ProblemsPlace) DataTable(org.dominokit.domino.ui.datatable.DataTable) ProblemCollectionPlace(com.playshogi.website.gwt.client.place.ProblemCollectionPlace) TextHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.TextHeaderFilter) SelectHeaderFilter(org.dominokit.domino.ui.datatable.plugins.filter.header.SelectHeaderFilter) Row(org.dominokit.domino.ui.grid.Row) Window(com.google.gwt.user.client.Window) SelectOption(org.dominokit.domino.ui.forms.SelectOption) TextNode(org.dominokit.domino.ui.utils.TextNode) ProblemCollectionDetails(com.playshogi.website.gwt.shared.models.ProblemCollectionDetails) org.dominokit.domino.ui.datatable.plugins(org.dominokit.domino.ui.datatable.plugins) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) EventBus(com.google.web.bindery.event.shared.EventBus) ProblemCollectionPropertiesForm(com.playshogi.website.gwt.client.widget.collections.ProblemCollectionPropertiesForm) List(java.util.List) Row_12(org.dominokit.domino.ui.grid.Row_12) elemental2.dom(elemental2.dom) HtmlContentBuilder(org.jboss.elemento.HtmlContentBuilder) Comparator(java.util.Comparator) TagsElement(com.playshogi.website.gwt.client.widget.problems.TagsElement) Button(org.dominokit.domino.ui.button.Button) ProblemCollectionPlace(com.playshogi.website.gwt.client.place.ProblemCollectionPlace) ProblemCollectionDetails(com.playshogi.website.gwt.shared.models.ProblemCollectionDetails) TableConfig(org.dominokit.domino.ui.datatable.TableConfig) ProblemsPlace(com.playshogi.website.gwt.client.place.ProblemsPlace)

Aggregations

ProblemsPlace (com.playshogi.website.gwt.client.place.ProblemsPlace)3 GWT (com.google.gwt.core.client.GWT)2 Window (com.google.gwt.user.client.Window)2 EventBus (com.google.web.bindery.event.shared.EventBus)2 AppPlaceHistoryMapper (com.playshogi.website.gwt.client.mvp.AppPlaceHistoryMapper)2 ViewLessonPlace (com.playshogi.website.gwt.client.place.ViewLessonPlace)2 TagsElement (com.playshogi.website.gwt.client.widget.problems.TagsElement)2 Comparator (java.util.Comparator)2 List (java.util.List)2 Button (org.dominokit.domino.ui.button.Button)2 ColumnConfig (org.dominokit.domino.ui.datatable.ColumnConfig)2 DataTable (org.dominokit.domino.ui.datatable.DataTable)2 TableConfig (org.dominokit.domino.ui.datatable.TableConfig)2 org.dominokit.domino.ui.datatable.plugins (org.dominokit.domino.ui.datatable.plugins)2 ASC (org.dominokit.domino.ui.datatable.plugins.SortDirection.ASC)2 SelectHeaderFilter (org.dominokit.domino.ui.datatable.plugins.filter.header.SelectHeaderFilter)2 TextHeaderFilter (org.dominokit.domino.ui.datatable.plugins.filter.header.TextHeaderFilter)2 LocalListDataStore (org.dominokit.domino.ui.datatable.store.LocalListDataStore)2 RecordsSorter (org.dominokit.domino.ui.datatable.store.RecordsSorter)2 SelectOption (org.dominokit.domino.ui.forms.SelectOption)2