Merge branch 'forum/buttons' into develop
This commit is contained in:
commit
10b9ce18ce
src
main/java/se/su/dsv/scipro/forum/panels
test/java/se/su/dsv/scipro/forum/panels
@ -13,7 +13,6 @@
|
||||
<textarea wicket:id="content" placeholder="Write here.."></textarea>
|
||||
</label>
|
||||
<label>Attachment: <input type="file" wicket:id="attachment" /></label>
|
||||
<button wicket:id="cancel">Cancel</button>
|
||||
<input type="submit" wicket:id="create" value="Post" />
|
||||
</form>
|
||||
</wicket:panel>
|
||||
|
@ -83,12 +83,6 @@ public class CreateForumThreadPanel extends Panel {
|
||||
form.add(upload = new FileUploadField(ATTACHMENT));
|
||||
upload.add(new AttachmentValidator(15));
|
||||
|
||||
form.add(new AjaxFallbackLink<Void>(CANCEL) {
|
||||
@Override
|
||||
public void onClick(final AjaxRequestTarget target) {
|
||||
cancelled(target);
|
||||
}
|
||||
});
|
||||
form.add(new AjaxFallbackButton(CREATE, form) {
|
||||
@Override
|
||||
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
|
||||
@ -103,13 +97,11 @@ public class CreateForumThreadPanel extends Panel {
|
||||
}
|
||||
|
||||
protected void threadCreated(AjaxRequestTarget target) { }
|
||||
protected void cancelled(AjaxRequestTarget target) { }
|
||||
|
||||
static final String FEEDBACK = "feedback";
|
||||
static final String FORM = "form";
|
||||
static final String SUBJECT = "subject";
|
||||
static final String CONTENT = "content";
|
||||
static final String ATTACHMENT = "attachment";
|
||||
static final String CANCEL = "cancel";
|
||||
static final String CREATE = "create";
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ public class ForumPanel extends Panel {
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
this.setVisible(false);
|
||||
createForumThreadPanel.setVisible(true);
|
||||
createForumThreadPanel.clean();
|
||||
createForumThreadPanel.getSubjectField().setEnabled(true);
|
||||
target.addComponent(wmc);
|
||||
}
|
||||
});
|
||||
@ -41,17 +43,13 @@ public class ForumPanel extends Panel {
|
||||
closePanel(target, wmc);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cancelled(AjaxRequestTarget target) {
|
||||
closePanel(target, wmc);
|
||||
}
|
||||
});
|
||||
createForumThreadPanel.setVisible(false);
|
||||
|
||||
wmc.add(new ViewForumPostsPanel(VIEW_POSTS, model) {
|
||||
@Override
|
||||
public void onReply(IModel<ForumThread> thread, AjaxRequestTarget target){
|
||||
newMessageButton.setVisible(false);
|
||||
newMessageButton.setVisible(true);
|
||||
createForumThreadPanel.setVisible(true);
|
||||
createForumThreadPanel.setSubject(new Model<String>(thread.getObject().getSubject()));
|
||||
createForumThreadPanel.setThread(thread);
|
||||
|
@ -36,14 +36,13 @@ public class CreateForumThreadPanelTest extends SciProTest {
|
||||
@Mock ForumService forumService;
|
||||
@Mock Project project;
|
||||
|
||||
static boolean cancelCalled;
|
||||
static boolean createdCalled;
|
||||
|
||||
CreateForumThreadPanel panel;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
cancelCalled = createdCalled = false;
|
||||
createdCalled = false;
|
||||
|
||||
panel = (CreateForumThreadPanel) tester.startPanel(new ITestPanelSource() {
|
||||
@Override
|
||||
@ -97,15 +96,6 @@ public class CreateForumThreadPanelTest extends SciProTest {
|
||||
verify(forumService, times(1)).createThread(eq(project), eq(user), eq(subject), eq(content), (FileUpload)isNull());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClickingCancelInvokesCallback() throws Exception {
|
||||
// when
|
||||
tester.executeAjaxEvent(path(panel.getId(), CreateForumThreadPanel.FORM, CreateForumThreadPanel.CANCEL), "onclick");
|
||||
|
||||
// then
|
||||
assertTrue("Cancel callback not invoked", cancelCalled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClickingCreateInvokesCallback() throws Exception {
|
||||
// given
|
||||
@ -138,8 +128,4 @@ class TestPanel extends CreateForumThreadPanel {
|
||||
CreateForumThreadPanelTest.createdCalled = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cancelled(final AjaxRequestTarget target) {
|
||||
CreateForumThreadPanelTest.cancelCalled = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user