Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Added button to delete hypothesis
Browse files Browse the repository at this point in the history
  • Loading branch information
hvarg committed Sep 9, 2021
1 parent 4dcc33f commit 6cbafbd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,23 +281,25 @@ public void onBrowserEvent(Event event) {
options.appendChild(el);
}

IronIcon iconNarrative = new IronIcon();
iconNarrative.addStyleName("inline-button");
iconNarrative.setIcon("assignment");
el = iconNarrative.getElement();
Event.sinkEvents(el, Event.ONCLICK);
Event.setEventListener(el, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
CloseableDialog dialog = new CloseableDialog();
Narrative narrativeEl = new Narrative(tloi);
dialog.setText("Execution narrative");
dialog.add(narrativeEl);
dialog.centerAndShow();
}
});
if (curStatus == Status.SUCCESSFUL) {
IronIcon iconNarrative = new IronIcon();
iconNarrative.addStyleName("inline-button");
iconNarrative.setIcon("assignment");
el = iconNarrative.getElement();
Event.sinkEvents(el, Event.ONCLICK);
Event.setEventListener(el, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
CloseableDialog dialog = new CloseableDialog();
Narrative narrativeEl = new Narrative(tloi);
dialog.setText("Execution narrative");
dialog.add(narrativeEl);
dialog.centerAndShow();
}
});

options.appendChild(el);
options.appendChild(el);
}

IronIcon iconDelete = new IronIcon();
iconDelete.addStyleName("delete-button");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

import org.diskproject.client.components.searchpanel.SearchableItem;
import org.diskproject.client.place.NameTokens;
import org.diskproject.client.rest.AppNotification;
import org.diskproject.client.rest.DiskREST;
import org.diskproject.shared.classes.common.TreeItem;
import org.diskproject.shared.classes.loi.TriggeredLOI;

import com.google.gwt.core.client.Callback;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.DivElement;
import com.google.gwt.dom.client.LabelElement;
Expand All @@ -20,14 +23,15 @@
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Window;
import com.vaadin.polymer.paper.widget.PaperIconButton;

public class HypothesisItem extends SearchableItem {
interface Binder extends UiBinder<Widget, HypothesisItem> {};
private static Binder uiBinder = GWT.create(Binder.class);

@UiField DivElement title, description, info, executions;
@UiField PaperIconButton editButton;
@UiField PaperIconButton editButton, deleteButton;
@UiField LabelElement tloiLabel;
private String strTitle, strDescription, strAuthor, strDate;
private String id;
Expand Down Expand Up @@ -117,4 +121,23 @@ void onEditButtonClicked(ClickEvent event) {
String token = NameTokens.hypotheses + "/" + HypothesisItem.username +"/" + HypothesisItem.domain + "/" + this.id;
History.newItem(token);
}

@UiHandler("deleteButton")
void onDelButtonClicked(ClickEvent event) {
HypothesisItem me = this;
if (Window.confirm("Are you sure you want to delete " + this.strTitle)) {
DiskREST.deleteHypothesis(this.id, new Callback<Void, Throwable>() {
@Override
public void onFailure(Throwable reason) {
AppNotification.notifyFailure(reason.getMessage());
}
@Override
public void onSuccess(Void result) {
AppNotification.notifySuccess("Deleted", 500);
//TODO: do some kind of update to remove this element
me.setVisible(false);
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,28 @@
.hyp-desc-row {
padding: 0px 5px 5px 30px;
}
.edit-hyp-button {
.edit-button-hyp {
width: 32px;
height: 32px;
padding: 3px;
}
.del-button-hyp {
width: 32px;
height: 32px;
padding: 5px;
}
.del-button-hyp:hover {
color: darkred;
}
</style>

<div class="hyp-container">
<div class="hyp-title-row">
<iron-icon icon="help-outline" style="color: orange; padding: 4px; height: 24px;"></iron-icon>
<div class="title" ui:field="title"></div>
<div class="info" ui:field="info"></div>
<p:PaperIconButton icon="create" ui:field="editButton" class="edit-hyp-button"></p:PaperIconButton>
<p:PaperIconButton icon="create" ui:field="editButton" class="edit-button-hyp"></p:PaperIconButton>
<p:PaperIconButton icon="delete" ui:field="deleteButton" class="del-button-hyp"></p:PaperIconButton>
</div>
<hr/>
<div class="hyp-desc-row">
Expand Down

0 comments on commit 6cbafbd

Please sign in to comment.