diff --git a/zanata-war/src/main/java/org/zanata/action/ProjectHome.java b/zanata-war/src/main/java/org/zanata/action/ProjectHome.java index a096165a3c..b04910b403 100644 --- a/zanata-war/src/main/java/org/zanata/action/ProjectHome.java +++ b/zanata-war/src/main/java/org/zanata/action/ProjectHome.java @@ -599,7 +599,7 @@ public void updateValidationOption(String name, String state) { update(); addMessage(StatusMessage.Severity.INFO, zanataMessages.getMessage( - "jsf.project.validation.updated", + "jsf.validation.updated", validatationId.getDisplayName(), state)); } diff --git a/zanata-war/src/main/java/org/zanata/action/VersionHome.java b/zanata-war/src/main/java/org/zanata/action/VersionHome.java index 867870299b..7a93b2850e 100644 --- a/zanata-war/src/main/java/org/zanata/action/VersionHome.java +++ b/zanata-war/src/main/java/org/zanata/action/VersionHome.java @@ -21,6 +21,7 @@ */ package org.zanata.action; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -51,11 +52,16 @@ import org.zanata.seam.scope.FlashScopeBean; import org.zanata.service.LocaleService; import org.zanata.service.SlugEntityService; +import org.zanata.service.ValidationService; import org.zanata.service.impl.LocaleServiceImpl; import org.zanata.util.ZanataMessages; +import org.zanata.webtrans.shared.model.ValidationAction; +import org.zanata.webtrans.shared.model.ValidationId; +import org.zanata.webtrans.shared.validation.ValidationFactory; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import lombok.Getter; import lombok.Setter; @@ -90,6 +96,9 @@ public class VersionHome extends SlugHome { @In private LocaleService localeServiceImpl; + @In + private ValidationService validationServiceImpl; + @In private SlugEntityService slugEntityServiceImpl; @@ -99,6 +108,9 @@ public class VersionHome extends SlugHome { @In private ZanataMessages zanataMessages; + private Map availableValidations = Maps + .newHashMap(); + @Override protected HProjectIteration loadInstance() { Session session = (Session) getEntityManager().getDelegate(); @@ -108,7 +120,7 @@ protected HProjectIteration loadInstance() { .using("slug", getSlug()) .using("project", projectDAO.getBySlug(projectSlug)).load(); } else { - //new version + // new version HProjectIteration iteration = new HProjectIteration(); HProject project = (HProject) projectDAO.getBySlug(projectSlug); project.addIteration(iteration); @@ -123,6 +135,21 @@ protected HProjectIteration loadInstance() { } } + @Restrict("#{s:hasPermission(versionHome.instance, 'update')}") + public void updateRequireTranslationReview(String key, boolean checked) { + getInstance().setRequireTranslationReview(checked); + update(); + if (checked) { + addMessage(StatusMessage.Severity.INFO, + zanataMessages + .getMessage("jsf.iteration.requireReview.enabled")); + } else { + addMessage(StatusMessage.Severity.INFO, + zanataMessages + .getMessage("jsf.iteration.requireReview.disabled")); + } + } + @Getter private AbstractAutocomplete localeAutocomplete = new AbstractAutocomplete() { @@ -191,6 +218,29 @@ public void onSelectItemAction() { } }; + public List getValidationList() { + List sortedList = + Lists.newArrayList(getValidations().values()); + Collections.sort(sortedList, + ValidationFactory.ValidationActionComparator); + return sortedList; + } + + private Map getValidations() { + if (availableValidations.isEmpty()) { + Collection validationList = + validationServiceImpl.getValidationActions(projectSlug, + slug); + + for (ValidationAction validationAction : validationList) { + availableValidations.put(validationAction.getId(), + validationAction); + } + } + + return availableValidations; + } + public void validateSuppliedId() { getInstance(); // this will raise an EntityNotFound exception // when id is invalid and conversation will not @@ -328,6 +378,52 @@ public void setSelectedProjectType(String selectedProjectType) { } } + public List getValidationStates() { + return Arrays.asList(ValidationAction.State.values()); + } + + @Restrict("#{s:hasPermission(versionHome.instance, 'update')}") + public void updateValidationOption(String name, String state) { + ValidationId validatationId = ValidationId.valueOf(name); + + for (Map.Entry entry : getValidations() + .entrySet()) { + if (entry.getKey().name().equals(name)) { + getValidations().get(validatationId).setState( + ValidationAction.State.valueOf(state)); + ensureMutualExclusivity(getValidations().get(validatationId)); + break; + } + getInstance().getCustomizedValidations().put(entry.getKey().name(), + entry.getValue().getState().name()); + } + + update(); + addMessage(StatusMessage.Severity.INFO, zanataMessages.getMessage( + "jsf.validation.updated", validatationId.getDisplayName(), + state)); + } + + /** + * If this action is enabled(Warning or Error), then it's exclusive + * validation will be turn off + * + * @param selectedValidationAction + */ + private void ensureMutualExclusivity( + ValidationAction selectedValidationAction) { + if (selectedValidationAction.getState() != ValidationAction.State.Off) { + for (ValidationAction exclusiveValAction : selectedValidationAction + .getExclusiveValidations()) { + getInstance().getCustomizedValidations().put( + exclusiveValAction.getId().name(), + ValidationAction.State.Off.name()); + getValidations().get(exclusiveValAction.getId()).setState( + ValidationAction.State.Off); + } + } + } + /** * Use FlashScopeBean to store message in page. Multiple ajax requests for * re-rendering statistics after updating will clear FacesMessages. diff --git a/zanata-war/src/main/resources/messages.properties b/zanata-war/src/main/resources/messages.properties index c564766df5..c258052de3 100644 --- a/zanata-war/src/main/resources/messages.properties +++ b/zanata-war/src/main/resources/messages.properties @@ -124,7 +124,6 @@ jsf.PageTitle=Zanata | Open Translation, for Everyone jsf.Reviewed=Reviewed jsf.Settings=Settings jsf.Time=Time -jsf.Translation=Translation jsf.UploadedTranslations=Uploaded translations jsf.UploadedSource=Uploaded source documents jsf.YourActivity=Your Activity @@ -140,6 +139,16 @@ jsf.EditHomePage=Edit Home Page #------- Shared --------- jsf.tooltip.MoreActions=More Actions +jsf.label.review=Review +jsf.Translation=Translation +jsf.validation.source=Source +jsf.validation.target=Target +jsf.validation.updated=Updated validation {0} to {1}. +jsf.CopyTrans=Copy Trans +jsf.Copytrans.message=Copy Trans attempts to reuse translations that have been entered in Zanata by matching them with unstranslated strings in your project/version. Consequently, Copy Trans is best used before translation and review work is initiated on a project. +jsf.Copytrans.message2=Each translation has to pass through each of these checks before it will be copied. +jsf.CopyTrans.Action.message=If all previous steps have passed, copy as translated. +jsf.CopyTrans.Action.message2=Unless previously marked as fuzzy. #------ [home] > Projects ------ ! 'Action' button @@ -203,8 +212,6 @@ jsf.ArchiveProject.Message=This will disable this project and remove it from the jsf.UnarchiveProject.Message=This will set the project's status to active and make it visible in the public projects list. jsf.project.readonly.Message=Read only prevents translations being entered. Your project will still be viewable by the public but no new translations can be added. jsf.project.writable.Message=Your project will be viewable by the public and new translations can be added. -jsf.project.validation.source=Source -jsf.project.validation.target=Target jsf.project.LanguageRemoved=Language '{0}' has been removed from project. jsf.project.LanguageAdded=Language '{0}' has been added to project. @@ -264,7 +271,6 @@ jsf.Permissions=Permissions jsf.project.MaintainerRemoved=Maintainer '{0}' has been removed from project. jsf.project.MaintainerAdded=Maintainer '{0}' has been added to project. jsf.project.status.updated=Updated project status '{0}'. -jsf.project.validation.updated=Updated validation {0} to {1}. jsf.field.optional=(optional) jsf.field.repository=Repository @@ -312,13 +318,10 @@ jsf.iteration.writable.Message=This version will be viewable by the public and n jsf.iteration.status.updated=Updated version status '{0}'. jsf.iteration.LanguageRemoved=Language '{0}' has been removed from version. jsf.iteration.LanguageAdded=Language '{0}' has been added to version. -jsf.CopyTrans=Copy Trans - -jsf.Copytrans.message=Copy Trans attempts to reuse translations that have been entered in Zanata by matching them with unstranslated strings in your project/version. Consequently, Copy Trans is best used before translation and review work is initiated on a project. -jsf.Copytrans.message2=Each translation has to pass through each of these checks before it will be copied. - -jsf.CopyTrans.Action.message=If all previous steps have passed, copy as translated. -jsf.CopyTrans.Action.message2=Unless previously marked as fuzzy. +jsf.iteration.requireReview.enabled=Enabled translation review +jsf.iteration.requireReview.disabled=Disabled translation review +jsf.iteration.copyTrans.start.question=Do you want to run Copy Trans on this version? +jsf.iteration.CopyTrans.message=This is automatically run whenever a new version is created ! used in coloured display tiles #FIXME this is actually longer, may not be necessary or should be named better @@ -337,6 +340,7 @@ jsf.CopyTrans.ClickHereToViewProgress=Please click here to view progress. jsf.iteration.CopyTrans.AlreadyStarted.flash=Someone else already started a #{messages['jsf.CopyTrans']} for this version. jsf.iteration.CopyTrans.NoDocuments=There are no documents in this project version. jsf.iteration.CopyTrans.Started=#{messages['jsf.CopyTrans']} started. +jsf.iteration.CopyTransOpts.tooltip=Set this version's #{messages['jsf.CopyTrans']} settings. jsf.iteration.tooltip.readonly=This version is currently read only @@ -386,8 +390,9 @@ jsf.iteration.CopyTrans.inProgress=#{messages['jsf.CopyTrans']} in progress... jsf.iteration.CopyTrans.started=Started #{viewAllStatusAction.copyTransStartTime} ago by #{pHandle.triggeredBy} jsf.iteration.CopyTrans.estimatedTimeRemaining=Estimated Time Remaining: #{viewAllStatusAction.copyTransEstimatedTimeLeft} jsf.iteration.CopyTrans.processedDocuments=Processed Documents: #{pHandle.documentsProcessed} of #{viewAllStatusAction.projectIteration.documents.size()} - jsf.iteration.requireTranslationReview=Require translation review +jsf.iteration.requireReview.message=If review is required an extra “reviewed” state will be added to translations and will not be considered finalised until a translation has reached this state. +jsf.iteration.requireReview.help=Help: Turning review on or off jsf.group.FindGroup=Find Group jsf.NoResultToDisplay=No result to display. diff --git a/zanata-war/src/main/webapp/WEB-INF/layout/project/settings-tab.xhtml b/zanata-war/src/main/webapp/WEB-INF/layout/project/settings-tab.xhtml index 9cd355d91d..489f37ee21 100644 --- a/zanata-war/src/main/webapp/WEB-INF/layout/project/settings-tab.xhtml +++ b/zanata-war/src/main/webapp/WEB-INF/layout/project/settings-tab.xhtml @@ -261,7 +261,7 @@ id="#{validationAction.id.name()}-example">

- #{messages['jsf.project.validation.source']} + #{messages['jsf.validation.source']}


                 
               

- #{messages['jsf.project.validation.target']} + #{messages['jsf.validation.target']}


                 #{messages['jsf.CopyTrans']}
 
     

#{messages['jsf.Copytrans.message']} - diff --git a/zanata-war/src/main/webapp/WEB-INF/layout/version/settings-tab.xhtml b/zanata-war/src/main/webapp/WEB-INF/layout/version/settings-tab.xhtml index fb180ad2f6..991d34e3c1 100644 --- a/zanata-war/src/main/webapp/WEB-INF/layout/version/settings-tab.xhtml +++ b/zanata-war/src/main/webapp/WEB-INF/layout/version/settings-tab.xhtml @@ -6,171 +6,322 @@ xmlns:s="http://jboss.org/schema/seam/taglib" xmlns:zanata="http://java.sun.com/jsf/composite/zanata"> - + -

#{messages['jsf.iteration.VersionSettings']}

+ + + + -
-
    -
  • - - - #{messages['jsf.General']} - -
  • -
  • - - - #{messages['jsf.Documents']} - -
  • -
  • - - - #{messages['jsf.Languages']} - -
  • -
  • - - - #{messages['jsf.Translation']} - + + + + + +

    #{messages['jsf.iteration.VersionSettings']}

    + +
    + + +
      +
    • +

      + #{messages['jsf.General']} +

      + + + + +
      + +
      +
      + + +
      + + #{messages['jsf.iteration.readonly']} + + +

      #{messages['jsf.iteration.readonly.Message']}

      +
      +
      + +
      + + + + + #{messages['jsf.iteration.writable']} + + +

      #{messages['jsf.iteration.writable.Message']}

      +
      +
      + + +
      + + + #{messages['jsf.iteration.UnArchiveThisVersion']} + + +

      #{messages['jsf.iteration.unarchive.Message']}

      +
      +
      + +
      + + + #{messages['jsf.iteration.ArchiveThisVersion']} + + +

      #{messages['jsf.iteration.archive.Message']}

      +
      +
      +
      +
      +
    • +
    • + Documents tab +
    • +
    • +

      + #{messages['jsf.Languages']} +

      + +
        + +
      • #{locale.retrieveDisplayName()}[#{locale.localeId}] + + + +
      • +
        +
      • + + + + #{result.retrieveDisplayName()}[#{result.localeId}] +
      +
      +
    • +
    • +

      + #{messages['jsf.Translation']} +

      + +

      #{messages['jsf.label.review']}

      + +
      + + +

      #{messages['jsf.iteration.requireReview.message']} + + +

      +
      + +
      -
        -
      • -

        - #{messages['jsf.General']} -

        - - - - -
        - -
        -
        - - -
        - - #{messages['jsf.iteration.readonly']} - - -

        #{messages['jsf.iteration.readonly.Message']}

        +

        #{messages['jsf.Validation']}

        + + +
          + +
        • +
          +
          + + +

          + #{validationAction.description} + + + #{messages['jsf.tooltip.More']} + … + +

          - - -
          - - - - - #{messages['jsf.iteration.writable']} - - -

          #{messages['jsf.iteration.writable.Message']}

          +
          +
          + + + + + + + + + +
          - - - -
          - - - #{messages['jsf.iteration.UnArchiveThisVersion']} - - -

          #{messages['jsf.iteration.unarchive.Message']}

          +
          +
        • -
        • - Documents tab -
        • -
        • -

          - #{messages['jsf.Languages']} -

          - -
            - -
          • #{locale.retrieveDisplayName()}[#{locale.localeId}] - - - -
          • -
            -
          • - - - - #{result.retrieveDisplayName()}[#{result.localeId}] - -
          • -
          -
          -
        • -
        • -

          - #{messages['jsf.Translation']} -

          - - -
        • -
        -
        +
    +
  • + +
+ + +
+

#{messages['jsf.CopyTrans']}

+ +

#{messages['jsf.Copytrans.message']} + + + +

+ +

#{messages['jsf.Copytrans.message2']}

+ + +
+
+
+

#{messages['jsf.iteration.copyTrans.start.question']}

+ +

#{messages['jsf.iteration.CopyTrans.message']}

+
+
+ + +
+
+
+ + + +
\ No newline at end of file