Commit d271c6c0 authored by Nugraha, Sigit's avatar Nugraha, Sigit
Browse files

Enable edit study description

parent 992de093
Pipeline #15364 passed with stage
in 1 minute and 59 seconds
package org.gesis.stardat.ui.view.study;
import java.util.HashMap;
import com.vaadin.ui.TextArea;
import org.gesis.stardat.entity.StudyUnit;
import org.gesis.stardat.helper.TriggerableWindowMaster;
import org.gesis.stardat.service.I18N;
import org.gesis.stardat.ui.windows.BaseStoreCancelWindow;
import org.vaadin.viritin.fields.*;
import org.vaadin.viritin.fluency.ui.FluentHasValue;
import com.vaadin.ui.*;
import org.vaadin.viritin.fields.IntegerField;
import org.vaadin.viritin.fields.MTextField;
import java.util.HashMap;
public class EditStudyDescriptionWindow extends BaseStoreCancelWindow{
......@@ -23,7 +24,7 @@ public class EditStudyDescriptionWindow extends BaseStoreCancelWindow{
public static final String CONTENT = "content";
private MTextField title = new MTextField();
private MTextField publicationYear = new MTextField();
private IntegerField publicationYear = new IntegerField();
private MTextField evaluationStart = new MTextField();
private MTextField evaluationEnd = new MTextField();
private MTextField publisher = new MTextField();
......@@ -37,8 +38,8 @@ public class EditStudyDescriptionWindow extends BaseStoreCancelWindow{
public EditStudyDescriptionWindow(String windowName, StudyUnit studyUnit, TriggerableWindowMaster master ) {
super( windowName );
setWidth( "550px" );
setHeight( "300px" );
setWidth( "1024px" );
setHeight( "600px" );
this.master = master;
this.studyUnit = studyUnit;
......@@ -55,8 +56,14 @@ public class EditStudyDescriptionWindow extends BaseStoreCancelWindow{
.withCaption( I18N.get( windowName + ".label" ) )
.withWidth( "200" );
if (studyUnit.getPublicationYear()!=null)
{publicationYear
.withValue( studyUnit.getPublicationYear().toString() );}
{
Integer year = null;
try {
year = Integer.parseInt(studyUnit.getPublicationYear().toString());
} catch (Exception e){}
publicationYear
.withValue( year );
}
publicationYear
.withCaption( I18N.get( windowName + ".publicationYear" ) )
.withWidth( "100" );
......@@ -82,16 +89,21 @@ public class EditStudyDescriptionWindow extends BaseStoreCancelWindow{
categories.setValue( studyUnit.getCategoriesAsString());}
categories.setCaption( I18N.get( windowName + ".categories" ) );
categories.setWidth( "200" );
categories.setRows( 6 );
categories.setDescription(I18N.get( windowName + ".categories.description" ));
if(studyUnit.getTopicsAsString()!=null) {
categories.setVisible( false ); // categories s complex object and not suitable for a normal String/Text operation
if(studyUnit.getTopicsAsString()!=null) {
topics.setValue( studyUnit.getTopicsAsString());}
topics.setCaption( I18N.get( windowName + ".topics" ) );
topics.setWidth( "200" );
topics.setVisible( false ); // topic s complex object and not suitable for a normal String/Text operation
topics.setRows( 6 );
topics.setDescription(I18N.get( windowName + ".topics.description" ));
if(studyUnit.getContent()!=null) {
content.setValue( studyUnit.getContent());}
content.setCaption( I18N.get( windowName + ".content" ) );
content.setWidth( "200" );
content.setRows( 6 );
getContentLayout().addComponents( title, publicationYear, evaluationStart, evaluationEnd, publisher, categories, topics, content );
}
......@@ -100,19 +112,19 @@ public class EditStudyDescriptionWindow extends BaseStoreCancelWindow{
@Override
protected boolean store() {
close();
getDDIEditor().removeWindow( this );
HashMap<String, Object> args = new HashMap<>();
args.put( TITLE, title.getValue() );
args.put( PUBLICATION_YEAR, publicationYear.getValue() );
args.put( EVALUATION_START, evaluationStart.getValue() );
args.put( EVALUATION_END, evaluationEnd.getValue() );
args.put( PUBLISHER, publisher.getValue() );
args.put( CATEGORIES, categories.getValue() );
args.put( TOPICS, topics.getValue() );
args.put( CONTENT, content.getValue() );
master.readyWith( GOAL + windowName, true, args );
return true;
close();
getDDIEditor().removeWindow( this );
HashMap<String, Object> args = new HashMap<>();
args.put( TITLE, title.getValue() );
args.put( PUBLICATION_YEAR, publicationYear.getValue() );
args.put( EVALUATION_START, evaluationStart.getValue() );
args.put( EVALUATION_END, evaluationEnd.getValue() );
args.put( PUBLISHER, publisher.getValue() );
// args.put( CATEGORIES, categories.getValue() );
// args.put( TOPICS, topics.getValue() );
args.put( CONTENT, content.getValue() );
master.readyWith( GOAL + windowName, true, args );
return true;
}
@Override
......
......@@ -186,6 +186,7 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
List<StudyGroup> groups = getGroups();
groupsGrid.setItems( groups );
if ( !groups.isEmpty() ) {
groupsGrid.select(groups.get(0));
refreshStudy( groups.get(0));
}
gesisLogger.createAndStoreDisplayEvent( VIEW_NAME, GesisLogEvent.DISPLAY_EVENT_TYPE_PAGE_SHOWN, "" );
......@@ -402,33 +403,30 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
cloneStudy.setVisible( false );
newQuestionnaire.setVisible( false );
Optional<StudyUnit> selectedStudy = studyUnitGrid.asSingleSelect().getFirstSelectedItem();
if ( selectedStudy.isPresent() )
final StudyUnit currentStudyUnit = getDDIEditor().getCurrentStudyUnit();
if ( currentStudyUnit != null)
{
if ( newStudy.isVisible() )
{
editStudy.setVisible( true );
// editStudyDescription.setVisible( true );
editStudyDescription.setVisible( true );
deleteStudy.setVisible( true );
cloneStudy.setVisible( true );
newQuestionnaire.setVisible( true );
}
else
{
groupsGrid.asSingleSelect().getFirstSelectedItem().ifPresent( sg ->
{
selectedStudy.ifPresent( su ->
final StudyGroup currentStudyGroup = getDDIEditor().getCurrentStudyGroup();
if( currentStudyGroup != null) {
if ( DDIEditorSecurityUtils.authorizeActions( currentStudyGroup.getId(), currentStudyUnit.getId(),
StudyGroupRole.ADMIN_STUDY, StudyGroupRole.RESEARCH_FELLOW ) )
{
if ( DDIEditorSecurityUtils.authorizeActions( sg.getId(), su.getId(),
StudyGroupRole.ADMIN_STUDY, StudyGroupRole.RESEARCH_FELLOW ) )
{
editStudyDescription.setVisible( true );
deleteStudy.setVisible( true );
cloneStudy.setVisible( true );
newQuestionnaire.setVisible( true );
}
} );
} );
editStudyDescription.setVisible( true );
deleteStudy.setVisible( true );
cloneStudy.setVisible( true );
newQuestionnaire.setVisible( true );
}
}
}
}
checkQuestionnaireActionRights();
......@@ -751,10 +749,25 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
break;
case EditStudyWindow.GOAL + EDITSTUDYWINDOWNAME:
case EditStudyDescriptionWindow.GOAL + EDITSTUDYDESCRIPTIONWINDOWNAME:
getDDIEditor().setWaiting();
StudyUnit editedStudy = getStudyUnitGrid().asSingleSelect().getValue();
editedStudy.setTitle( args.get( EditStudyWindow.TITLE ).toString() );
editedStudy.setTitle( args.get( EditStudyDescriptionWindow.TITLE ).toString() );
if( args.get( EditStudyDescriptionWindow.PUBLICATION_YEAR ) != null )
editedStudy.setPublicationYear( args.get( EditStudyDescriptionWindow.PUBLICATION_YEAR ).toString() );
if( args.get( EditStudyDescriptionWindow.EVALUATION_START ) != null )
editedStudy.setDateofCollectionStart( args.get( EditStudyDescriptionWindow.EVALUATION_START ).toString() );
if( args.get( EditStudyDescriptionWindow.EVALUATION_END ) != null )
editedStudy.setDateofCollectionEnd( args.get( EditStudyDescriptionWindow.EVALUATION_END ).toString() );
if( args.get( EditStudyDescriptionWindow.PUBLISHER ) != null )
editedStudy.setPublisher( args.get( EditStudyDescriptionWindow.PUBLISHER ).toString() );
// if( args.get( EditStudyDescriptionWindow.CATEGORIES ) != null )
// editedStudy.setCategories( args.get( EditStudyDescriptionWindow.CATEGORIES ).toString() );
// if( args.get( EditStudyDescriptionWindow.TOPICS ) != null )
// editedStudy.setTopics( args.get( EditStudyDescriptionWindow.TOPICS ).toString() );
if( args.get( EditStudyDescriptionWindow.CONTENT ) != null )
editedStudy.setContent( args.get( EditStudyDescriptionWindow.CONTENT ).toString() );
editedStudy.save();
entityService.getRestClient().saveElement( editedStudy.getDdiStore(),
......@@ -767,6 +780,7 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
getDDIEditor().processingSucceeded();
break;
case DeleteStudyWindow.GOAL + DELETESTUDYWINDOWNAME:
getDDIEditor().setWaiting();
......
......@@ -189,8 +189,8 @@ SelectionView.Study.button.cloneQuestionnaire = Fragebogen klonen
SelectionView.Study.button.editQuestion = Frage editieren
SelectionView.study.table.column.header.name= Name
SelectionView.Study.button.editStudy = Studie editieren
SelectionView.Study.button.editStudyDescription = Studienbeschreibung editieren
SelectionView.Study.button.editStudy = Studie titel editieren
SelectionView.Study.button.editStudyDescription = Studie editieren
SelectionView.Study.button.deleteStudy = Studie löschen
SelectionView.Study.button.editQuestionnaire = Fragebogen editieren
SelectionView.Study.button.deleteQuestionnaire = Fragebogen löschen
......@@ -579,7 +579,7 @@ NewStudyWindow.label = Name der Studie
NewStudyWindow.fileName = Dateiname
NewStudyWindow.comment = Bearbeitungsgrund
EditStudyWindow.title = Studie editieren
EditStudyWindow.title = Studie titel editieren
EditStudyWindow.store = Speichern
EditStudyWindow.cancel = Abbrechen
EditStudyWindow.help = Studie "{0}" editieren.
......@@ -1084,8 +1084,8 @@ EditStudyDescriptionWindow.topics = Themen
EditStudyDescriptionWindow.content = Inhalt
EditStudyDescriptionWindow.store = Speichern
EditStudyDescriptionWindow.cancel = Abbrechen
EditStudyDescriptionWindow.help = Studienbeschreibung editieren
EditStudyDescriptionWindow.title = Studienbeschreibung editieren
EditStudyDescriptionWindow.help =
EditStudyDescriptionWindow.title = Studieeditieren
EditStudyDescriptionWindow.categories.description = ZA-Kategorienschema
EditStudyDescriptionWindow.topics.description = CESSDA-Themen-Klassifikation
......
......@@ -147,8 +147,8 @@ SelectionView.Study.button.cloneQuestionnaire = Clone questionnaire
SelectionView.Study.button.editQuestion = edit Question
SelectionView.study.table.column.header.name= Name
SelectionView.Study.button.editStudy = Edit study
SelectionView.Study.button.editStudyDescription = Edit study description
SelectionView.Study.button.editStudy = Edit study title
SelectionView.Study.button.editStudyDescription = Edit study
SelectionView.Study.button.deleteStudy = Delete study
SelectionView.Study.button.editQuestionnaire = Edit questionnaire
SelectionView.Study.button.deleteQuestionnaire = Delete questionnaire
......@@ -569,7 +569,7 @@ NewStudyWindow.label = Name of the study
NewStudyWindow.fileName = file name
NewStudyWindow.comment = Edit reason
EditStudyWindow.title = Edit study
EditStudyWindow.title = Edit study title
EditStudyWindow.store = Save
EditStudyWindow.cancel = Cancel
EditStudyWindow.help =
......@@ -1079,8 +1079,8 @@ EditStudyDescriptionWindow.topics = Topics
EditStudyDescriptionWindow.content = Content
EditStudyDescriptionWindow.store = Save
EditStudyDescriptionWindow.cancel = Cancel
EditStudyDescriptionWindow.help = Edit study description
EditStudyDescriptionWindow.title = Edit study description
EditStudyDescriptionWindow.help =
EditStudyDescriptionWindow.title = Edit study
EditStudyDescriptionWindow.categories.description = ZA categories scheme
EditStudyDescriptionWindow.topics.description = CESSDA Topic Classification
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment