Use accessbility checks
This commit is contained in:
@@ -39,6 +39,7 @@ module.exports = function (options) {
|
||||
creatorId: request.user.id,
|
||||
name: translationArtifactVersion.name,
|
||||
artifactVersionId: translationArtifactVersion.artifactVersionId,
|
||||
accessibility: translationArtifactVersion.accessibility,
|
||||
userId: request.user.id,
|
||||
dialectId: translationArtifactVersion.dialectId,
|
||||
forkedFromId: translationArtifactVersion.id,
|
||||
@@ -53,6 +54,7 @@ module.exports = function (options) {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
chapterId: translationChapter.chapterId,
|
||||
index: translationChapter.index,
|
||||
translationChunks: translationChapter.translationChunks.map(translationChunk => {
|
||||
if (translationChunk.translation) {
|
||||
existingTranslation[translationChunk.chunkId] = {
|
||||
@@ -198,6 +200,7 @@ module.exports = function (options) {
|
||||
creatorId: userId,
|
||||
name: dialect.name,
|
||||
artifactVersionId: artifactVersion.id,
|
||||
accessibility: artifactVersion.artifact.accessibility,
|
||||
dialectId: dialect.id,
|
||||
userId: userId,
|
||||
owner: {
|
||||
@@ -211,6 +214,7 @@ module.exports = function (options) {
|
||||
return {
|
||||
creatorId: userId,
|
||||
chapterId: chapter.id,
|
||||
index: chapter.index,
|
||||
translationChunks: chapter.chunks.map(chunk => {
|
||||
return {
|
||||
creatorId: userId,
|
||||
@@ -246,6 +250,7 @@ module.exports = function (options) {
|
||||
creatorId: userId,
|
||||
name: artifactVersion.translationArtifactVersions[0].name,
|
||||
artifactVersionId: artifactVersion.translationArtifactVersions[0].artifactVersionId,
|
||||
accessibility: artifactVersion.artifact.accessibility,
|
||||
userId: userId,
|
||||
dialectId: artifactVersion.translationArtifactVersions[0].dialectId,
|
||||
forkedFromId: artifactVersion.translationArtifactVersions[0].id,
|
||||
@@ -260,6 +265,7 @@ module.exports = function (options) {
|
||||
return {
|
||||
creatorId: userId,
|
||||
chapterId: chapter.id,
|
||||
index: chapter.index,
|
||||
translationChunks: chapter.chunks.map(chunk => {
|
||||
return {
|
||||
creatorId: userId,
|
||||
|
||||
@@ -113,6 +113,7 @@ module.exports = function (options) {
|
||||
url: request.body.url,
|
||||
dialectId: dialect.id,
|
||||
licenseId: "copyright",
|
||||
accessibility: request.body.accessibility,
|
||||
artifactVersions: [
|
||||
{
|
||||
creatorId: request.user.id,
|
||||
|
||||
@@ -853,8 +853,9 @@ module.exports = function (options) {
|
||||
.string(translationArtifactVersion.id)
|
||||
|
||||
var cellIndex = 6
|
||||
for (const i in translationArtifactVersion.translationChapters) {
|
||||
const translationChapter = translationArtifactVersion.translationChapters[i]
|
||||
const translationChapters = translationArtifactVersion.translationChapters.sort((a, b) => a.index - b.index)
|
||||
for (const i in translationChapters) {
|
||||
const translationChapter = translationChapters[i]
|
||||
const translationChunks = translationChapter.translationChunks.sort((a,b) => a.index - b.index)
|
||||
for (const j in translationChunks) {
|
||||
const translationChunk = translationChunks[j]
|
||||
|
||||
@@ -395,6 +395,7 @@ module.exports = function (options) {
|
||||
name: translationArtifactVersion.artifactVersion.artifact.dialect.name,
|
||||
artifactVersionId: translationArtifactVersion.artifactVersionId,
|
||||
dialectId: translationArtifactVersion.dialect.id,
|
||||
accessibility: translationArtifactVersion.accessibility,
|
||||
backTranslationFromId: translationArtifactVersion.id,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
@@ -407,6 +408,7 @@ module.exports = function (options) {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
chapterId: translationChapter.chapterId,
|
||||
index: translationChapter.index,
|
||||
translationChunks: translationChapter.translationChunks.map(translationChunk => {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
|
||||
@@ -322,6 +322,7 @@ module.exports = function (options) {
|
||||
creatorId: request.user.id,
|
||||
name: dialect.name,
|
||||
artifactVersionId: artifactVersion.id,
|
||||
accessibility: artifactVersion.artifact.accessibility,
|
||||
dialectId: dialect.id,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
@@ -334,6 +335,7 @@ module.exports = function (options) {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
chapterId: chapter.id,
|
||||
index: chapter.index,
|
||||
translationChunks: chapter.chunks.map(chunk => {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
|
||||
@@ -10,6 +10,9 @@ block content
|
||||
.container
|
||||
.center
|
||||
h1 #{artifactVersion.artifact.name}
|
||||
if artifactVersion.artifact.accessibility == "private"
|
||||
i.right.medium.material-icons lock
|
||||
|
||||
h2 #{artifactVersion.tag}
|
||||
p.flow-text
|
||||
each ownerEntity, index in artifactVersion.artifact.owner.ownerEntities
|
||||
@@ -35,7 +38,7 @@ block content
|
||||
p.flow-text No chapters added
|
||||
else
|
||||
.row
|
||||
each chapter in artifactVersion.chapters
|
||||
each chapter in artifactVersion.chapters.sort((a, b) => a.index - b.index)
|
||||
.col.s12
|
||||
a(href=`/v/${artifactVersion.id}/chapters/${chapter.id}`)
|
||||
.card-panel
|
||||
|
||||
4
server/views/js/init-accessibility-select.js
Normal file
4
server/views/js/init-accessibility-select.js
Normal file
@@ -0,0 +1,4 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var elems = document.querySelectorAll('#accessibility-select');
|
||||
var instances = M.FormSelect.init(elems, {});
|
||||
});
|
||||
@@ -5,18 +5,37 @@ block content
|
||||
.center
|
||||
h1 Library
|
||||
|
||||
.row
|
||||
.col.s12
|
||||
form.row(action="/library/add", method="post")
|
||||
.row
|
||||
.col.s12
|
||||
form.row(action="/library/add", method="post")
|
||||
.col.s12.input-field
|
||||
input#name(type="text", name="name", value=artifact.name)
|
||||
label(for="name") Artifact Name
|
||||
.col.s12.input-field
|
||||
input#url(type="text", name="url", value=artifact.url)
|
||||
label(for="url") Artifact Url
|
||||
if artifact.id == null
|
||||
.col.s12.input-field
|
||||
input#name(type="text", name="name", value=artifact.name)
|
||||
label(for="name") Artifact Name
|
||||
.col.s12.input-field
|
||||
input#url(type="text", name="url", value=artifact.url)
|
||||
label(for="url") Artifact Url
|
||||
if artifact.id == null
|
||||
.col.s12.input-field
|
||||
input#version(type="text", name="version", value=artifact.version)
|
||||
label(for="version") First Version Number
|
||||
.col.s12
|
||||
button.btn.black(type="submit") add artifact
|
||||
input#version(type="text", name="version", value=artifact.version)
|
||||
label(for="version") First Version Number
|
||||
.col.s12.input-field
|
||||
p
|
||||
label
|
||||
input(type="radio", name="accessibility", value="public")
|
||||
span Public
|
||||
br
|
||||
small Anyone can see and add translations
|
||||
p
|
||||
label
|
||||
input(type="radio", name="accessibility", value="permissioned")
|
||||
span Permissioned
|
||||
br
|
||||
small Anyone can see but restrict translations
|
||||
p
|
||||
label
|
||||
input(type="radio", name="accessibility", value="private")
|
||||
span Private
|
||||
br
|
||||
small Restrict who can see and translate project
|
||||
.col.s12
|
||||
button.btn.black(type="submit") add artifact
|
||||
|
||||
@@ -58,7 +58,7 @@ block content
|
||||
//- TODO: Give summary of chapters...
|
||||
|
||||
h2 Chapters
|
||||
each translationChapter in translationArtifactVersion.translationChapters
|
||||
each translationChapter in translationArtifactVersion.translationChapters.sort((a,b) => a.index - b.index)
|
||||
p.flow-text
|
||||
small translate
|
||||
br
|
||||
|
||||
Reference in New Issue
Block a user