Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Project and version page
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Mar 6, 2014
1 parent 4e27af8 commit bbce1e1
Show file tree
Hide file tree
Showing 23 changed files with 326 additions and 256 deletions.
4 changes: 2 additions & 2 deletions zanata-war/src/main/java/org/zanata/action/ProjectHome.java
Expand Up @@ -310,7 +310,7 @@ public void validateSuppliedId() {
}

@Transactional
@Restrict("#{s:hasPermission(projectHome.instance, 'update')}")

public void updateCopyTrans(String action, String value) {
copyTransOptionsModel.setInstance(getInstance()
.getDefaultCopyTransOpts());
Expand All @@ -321,7 +321,7 @@ public void updateCopyTrans(String action, String value) {

update();
addMessage(StatusMessage.Severity.INFO,
zanataMessages.getMessage("jsf.project.CopyTransOpts.saved"));
zanataMessages.getMessage("jsf.project.CopyTransOpts.updated"));
}

public void initialize() {
Expand Down
77 changes: 66 additions & 11 deletions zanata-war/src/main/java/org/zanata/action/VersionHome.java
Expand Up @@ -111,6 +111,10 @@ public class VersionHome extends SlugHome<HProjectIteration> {
@Setter
private boolean isNewInstance = false;

@Getter
@Setter
private String selectedProjectType;

public void createNew() {
isNewInstance = true;
}
Expand Down Expand Up @@ -332,6 +336,59 @@ public int compare(HLocale hLocale, HLocale hLocale2) {
return locales;
}

public List<HLocale> getProjectActiveLocales() {
List<HLocale> projectLocales;
if (getInstance().getProject().isOverrideLocales()) {
projectLocales =
Lists.newArrayList(getInstance().getProject()
.getCustomizedLocales());
} else {
projectLocales = localeServiceImpl.getSupportedLocales();
}
Collections.sort(projectLocales, new Comparator<HLocale>() {
@Override
public int compare(HLocale hLocale, HLocale hLocale2) {
return hLocale.retrieveDisplayName().compareTo(
hLocale2.retrieveDisplayName());
}
});
return projectLocales;
}

public boolean isLocalesSameAsProject() {
return getInstanceActiveLocales().equals(getProjectActiveLocales());
}

public boolean isValidationsSameAsProject() {
return getInstance().getCustomizedValidations().equals(
getInstance().getProject().getCustomizedValidations());
}

public void copyValidationFromProject() {
getInstance().getCustomizedValidations().clear();
getInstance().getCustomizedValidations().putAll(
getInstance().getProject().getCustomizedValidations());
availableValidations.clear();
update();
addMessage(
StatusMessage.Severity.INFO,
zanataMessages
.getMessage("jsf.iteration.CopyProjectValidations.message"));
}

public void copyLanguagesFromProject() {
getInstance().setOverrideLocales(
getInstance().getProject().isOverrideLocales());
getInstance().getCustomizedLocales().clear();
getInstance().getCustomizedLocales().addAll(
getInstance().getProject().getCustomizedLocales());
update();
addMessage(
StatusMessage.Severity.INFO,
zanataMessages
.getMessage("jsf.iteration.CopyProjectLanguages.message"));
}

@Override
@Restrict("#{s:hasPermission(versionHome.instance, 'update')}")
public String update() {
Expand Down Expand Up @@ -367,20 +424,18 @@ public void updateStatus(char initial) {
"jsf.iteration.status.updated", EntityStatus.valueOf(initial)));
}

@Getter
@Setter
private String selectedProjectType;

public void updateSelectedProjectType(ValueChangeEvent e) {
selectedProjectType = (String) e.getNewValue();
updateProjectType();
if (!StringUtils.isEmpty(selectedProjectType)
&& !selectedProjectType.equals("null")) {
ProjectType projectType = ProjectType.valueOf(selectedProjectType);
getInstance().setProjectType(projectType);
} else {
getInstance().setProjectType(null);
}
}

public void copyProjectTypeFromProject() {
getInstance().setProjectType(
getInstance().getProject().getDefaultProjectType());
addMessage(StatusMessage.Severity.INFO,
zanataMessages
.getMessage("jsf.iteration.CopyProjectType.message"));
update();
}

private void updateProjectType() {
Expand Down
12 changes: 9 additions & 3 deletions zanata-war/src/main/resources/messages.properties
Expand Up @@ -293,7 +293,7 @@ jsf.YouAreNoLongerMaintainerForThisProject=You are no longer a maintainer for th
#------ [home] > Projects > [project-id] > [version-id] > Copy Translations ------
# Some of these strings are only visible while copytrans is running
jsf.project.CopyTransOpts.title=#{messages['jsf.CopyTrans']} Options
jsf.project.CopyTransOpts.saved=#{messages['jsf.CopyTrans']} options saved.
jsf.project.CopyTransOpts.updated=#{messages['jsf.CopyTrans']} options updated.
jsf.iteration.CopyTrans.Condition=Condition
jsf.iteration.CopyTrans.Condition.onContentMismatch=On content mismatch
jsf.iteration.CopyTrans.Condition.onContentMismatch.details=If the translations are not identical
Expand Down Expand Up @@ -326,6 +326,12 @@ 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
jsf.iteration.CopyProjectType.label=Copy project type from project
jsf.iteration.CopyProjectLanguages.label=Copy languages from project
jsf.iteration.CopyProjectValidation.label=Copy translation validation settings from project
jsf.iteration.CopyProjectLanguages.message=Copied language settings from project
jsf.iteration.CopyProjectValidations.message=Copied validation settings from project
jsf.iteration.CopyProjectType.message=Copied project type from project

! used in coloured display tiles
#FIXME this is actually longer, may not be necessary or should be named better
Expand Down Expand Up @@ -410,8 +416,8 @@ jsf.ConfirmExportTMXIter=Are you sure you want to export this project version to

#------ [home] > Projects > [project-id] > [version-id] > Source Documents ------
#------ [home] > Projects > [project-id] > [version-id] > Documents ([locale]) ------
jsf.pager.NextPage=next
jsf.pager.PreviousPage=prev
jsf.pager.NextPage=Next
jsf.pager.PreviousPage=Previous

jsf.iteration.ExportTMXIter=Export Version to TMX
jsf.iteration.ExportTMX.Language=Export {0} Documents to TMX
Expand Down
Expand Up @@ -33,7 +33,8 @@
<div class="form__item">
<h:outputLabel for="slug">
#{messages['jsf.ProjectId']}
<span class="txt--meta"><i class="i i--info" title="#{messages['jsf.SlugExample']}" data-original-title="#{messages['jsf.SlugExample']}"></i></span>
<span class="txt--meta"><i class="i i--info"
title="#{messages['jsf.SlugExample']}"></i></span>
</h:outputLabel>
<s:decorate id="slugField" template="../field.xhtml" enclose="true">
<h:inputText rendered="#{projectHome.managed}" disabled="true"
Expand Down Expand Up @@ -109,8 +110,8 @@
<label for="project-type-null"
class="form__radio__label">#{messages['jsf.projectType.NoSelection']} <span
class="txt--meta">#{messages['jsf.projectType.detail.noSelection']}
<i class="i i--info" title="#{messages['jsf.projectType.detail.noSelection.message']}"
data-original-title="#{messages['jsf.projectType.detail.noSelection.message']}"></i></span>
<i class="i i--info"
title="#{messages['jsf.projectType.detail.noSelection.message']}"></i></span>
</label>
</div>
</li>
Expand Down
Expand Up @@ -15,6 +15,10 @@
function onRestrictedByRoleValueChanged(key, checked) {
bindRestrictedByRoleValue(key, checked);
}

function getUserRoleId() {
return "[id='#{rich:clientId('user-roles')}']";
}
</script>

<a4j:jsFunction name="bindValidationValue"
Expand All @@ -33,7 +37,7 @@

<a4j:jsFunction name="bindRestrictedByRoleValue" limitRender="true"
render="user-roles, pageMessages"
oncomplete="jQuery('#settings-permissions-form').zanataForm('appendCheckboxes')"
oncomplete="zanata.form.appendCheckboxes(getUserRoleId())"
action="#{projectHome.setRestrictedByRole(key, checked)}">
<a4j:param name="val1" assignTo="#{key}"/>
<a4j:param name="val2" assignTo="#{checked}"/>
Expand Down Expand Up @@ -263,10 +267,10 @@

<p class="txt--meta l--push-bottom-quarter">
#{validationAction.description}
<a href="#" class="button--link js-reveal__toggle" title=""
<a href="#" class="button--link js-reveal__toggle"
data-target="##{validationAction.id.name()}-example"
data-toggle-title="#{messages['jsf.tooltip.HideExample']}"
data-original-title="#{messages['jsf.tooltip.ShowExample']}">
title="#{messages['jsf.tooltip.ShowExample']}">
<span class="js-reveal__toggle__text"
data-toggle-value="Less">
#{messages['jsf.tooltip.More']}
Expand Down Expand Up @@ -331,8 +335,7 @@

<p>#{messages['jsf.Copytrans.message']}
<a href="http://zanata.org/help/reuse/copytrans-explained/"
title="#{messages['jsf.project.CopyTransOpts.tooltip']}"
data-original-title="#{messages['jsf.project.CopyTransOpts.tooltip']}">
title="#{messages['jsf.project.CopyTransOpts.tooltip']}">
<i class="i i--help"></i>
</a>
</p>
Expand All @@ -359,6 +362,7 @@
<span class="txt--meta">@#{maintainer.account.username}</span>
<a4j:commandLink
action="#{projectHome.removeMaintainer(maintainer)}"
oncomplete="zanata.form.appendCheckboxes(getUserRoleId())"
styleClass="l--float-right txt--danger reveal__target"
render="settings-permissions-form,maintainers-size,maintainers_content,pageMessages">
<i class="i--large i--remove"></i>
Expand All @@ -377,7 +381,7 @@
maxlength="80" minlength="3" id="maintainerAutocomplete"
fetchValue="#{result.account.username}"
render="settings-permissions-form,maintainers-size, maintainers_content, pageMessages"
oncomplete="focusCurrentActiveInput()"
oncomplete="zanata.form.appendCheckboxes(getUserRoleId());focusCurrentActiveInput()"
placeholder="#{messages['jsf.SearchUsers']}">

<span class="w--r-1 bx--round l--push-right-quarter">
Expand All @@ -392,15 +396,15 @@
</ul>
<hr/>

<div class="l--push-bottom-half">
<s:div styleClass="l--push-bottom-half" id="user-roles">
<zanata:checkbox label="#{messages['jsf.RestrictRoleAccessMessage']}"
onValueChanged="onRestrictedByRoleValueChanged"
labelStyle="js-reveal__toggle l--push-bottom-0"
styleClass="js-form__restricted-by-role"
checked="#{projectHome.instance.isRestrictedByRoles()}"
value="restrict-access"/>
<s:div id="user-roles"
styleClass="#{projectHome.instance.restrictedByRoles?'is-active': 'is-hidden'} bg--high l--pad-top-quarter l--pad-h-quarter">
<s:div styleClass="bg--high l--pad-top-quarter l--pad-h-quarter"
rendered="#{projectHome.instance.restrictedByRoles}">
<ul class="g--tighter">
<ui:repeat value="#{projectHome.availableRoles}" var="availableRole">
<li class="g__item w--1-3 w--1-2-s">
Expand All @@ -412,7 +416,7 @@
</ui:repeat>
</ul>
</s:div>
</div>
</s:div>
</h:form>
</li>
<li id="settings-notes">
Expand Down
Expand Up @@ -4,23 +4,24 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:zanata="http://java.sun.com/jsf/composite/zanata"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j">
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">

<div class="panel">
<div class="panel__header">
<div class="panel__header__actions">
<zanata:sortlist id="projects-project_sorting"
sortAction="#{projectHomeAction.sortVersionList()}"
render="versions_form"
oncomplete="refreshTooltip('#{rich:clientId('versions_form')}')"
sortingList="#{projectHomeAction.versionSortingList}"/>

<s:fragment
rendered="#{s:hasPermission(projectHome.instance, 'update')}">
<div
class="dropdown dropdown--header dropdown--small dropdown--right dropdown--inline js-dropdown">
<a class="dropdown__toggle js-dropdown__toggle" href="#"
title="#{messages['jsf.tooltip.MoreActions']}"
data-original-title="#{messages['jsf.tooltip.MoreActions']}"><i
title="#{messages['jsf.tooltip.MoreActions']}"><i
class="i i--ellipsis"></i></a>
<ul class="dropdown__content js-dropdown__content" role="content"
aria-labelledby="dropdownContent">
Expand Down Expand Up @@ -61,8 +62,7 @@
class="dropdown dropdown--small dropdown--inline dropdown--single list__item__dropdown js-dropdown">
<a href="#"
class="dropdown__toggle js-dropdown__toggle txt--meta"
title="#{messages['jsf.tooltip.TranslateOptions']}"
data-original-title="#{messages['jsf.tooltip.TranslateOptions']}">
title="#{messages['jsf.tooltip.TranslateOptions']}">
<span class="is-invisible">
#{messages['jsf.tooltip.TranslateOptions']}
</span>
Expand Down
Expand Up @@ -21,8 +21,7 @@
<div
class="dropdown dropdown--header dropdown--small dropdown--right dropdown--inline js-dropdown">
<a class="dropdown__toggle js-dropdown__toggle" href="#"
title="#{messages['jsf.tooltip.MoreActions']}"
data-original-title="#{messages['jsf.tooltip.MoreActions']}"><i
title="#{messages['jsf.tooltip.MoreActions']}"><i
class="i i--ellipsis"></i></a>
<ul class="dropdown__content js-dropdown__content" role="content"
aria-labelledby="dropdownContent">
Expand Down
Expand Up @@ -21,8 +21,7 @@
<div
class="dropdown dropdown--header dropdown--small dropdown--right dropdown--inline js-dropdown">
<a class="dropdown__toggle js-dropdown__toggle" href="#"
title="#{messages['jsf.tooltip.MoreActions']}"
data-original-title="#{messages['jsf.tooltip.MoreActions']}"><i
title="#{messages['jsf.tooltip.MoreActions']}"><i
class="i i--ellipsis"></i>
</a>
<ul class="dropdown__content js-dropdown__content" role="content"
Expand Down
Expand Up @@ -78,6 +78,7 @@
<div class="panel__header__actions">
<zanata:sortlist id="documents-document_sorting"
sortAction="#{versionHomeAction.sortDocumentList()}"
oncomplete="refreshTooltip('#{rich:clientId('documents-document_form')}');refreshTooltip('documentsDocumentSearch')"
render="documents-document_form"
sortingList="#{versionHomeAction.documentSortingList}"/>

Expand All @@ -86,15 +87,14 @@
<div
class="dropdown dropdown--header dropdown--small dropdown--right dropdown--inline js-dropdown">
<a class="dropdown__toggle js-dropdown__toggle" href="#"
title="#{messages['jsf.tooltip.MoreActions']}"
data-original-title="#{messages['jsf.tooltip.MoreActions']}"><i
title="#{messages['jsf.tooltip.MoreActions']}"><i
class="i i--ellipsis"></i></a>
<ul class="dropdown__content js-dropdown__content" role="content"
aria-labelledby="dropdownContent">
<s:fragment rendered="#{versionHomeAction.documentUploadAllowed}">
<li>
<a href="#" class="i__item--right"
data-original-title="#{messages['jsf.SupportedUploadFormats']}"
title="#{messages['jsf.SupportedUploadFormats']}"
onclick="openUploadSourceDocPanel()">
#{messages['jsf.UploadSourceDocuments']}
<i class="i i--import i__item__icon"></i>
Expand Down Expand Up @@ -135,7 +135,7 @@
rendered="#{versionHomeAction.documentUploadAllowed}">
<p>
<a href="#" class="button--primary"
data-original-title="#{messages['jsf.SupportedUploadFormats']}"
title="#{messages['jsf.SupportedUploadFormats']}"
onclick="openUploadSourceDocPanel()">
#{messages['jsf.UploadSourceDocuments']}
</a>
Expand All @@ -154,8 +154,7 @@
<div
class="dropdown dropdown--small dropdown--inline dropdown--single js-dropdown">
<a class="dropdown__toggle js-dropdown__toggle txt--meta"
title="" href="#"
data-original-title="#{messages['jsf.tooltip.TranslateOptions']}">
title="#{messages['jsf.tooltip.TranslateOptions']}" href="#">
<span class="is-invisible">
#{messages['jsf.tooltip.TranslateOptions']}
</span>
Expand Down Expand Up @@ -261,15 +260,15 @@
<zanata:sortlist id="documents-language_sorting"
sortAction="#{versionHomeAction.sortLanguageList()}"
render="documents-language_list"
oncomplete="refreshTooltip('#{rich:clientId('documents-language_list')}')"
sortingList="#{versionHomeAction.languageSortingList}"/>

<s:fragment
rendered="#{s:hasPermission(versionHomeAction.version, 'update')}">
<div
class="dropdown dropdown--header dropdown--small dropdown--right dropdown--inline js-dropdown">
<a class="dropdown__toggle js-dropdown__toggle" href="#"
title="#{messages['jsf.tooltip.MoreActions']}"
data-original-title="#{messages['jsf.tooltip.MoreActions']}"><i
title="#{messages['jsf.tooltip.MoreActions']}"><i
class="i i--ellipsis"></i></a>
<ul class="dropdown__content js-dropdown__content" role="content"
aria-labelledby="dropdownContent">
Expand Down

0 comments on commit bbce1e1

Please sign in to comment.