Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status visibility setting #9

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.Transient;
import lombok.Data;
import de.uoc.dh.idh.autodone.utils.Visibility;


@Data()
@Entity()
Expand Down Expand Up @@ -50,6 +54,10 @@ public class GroupEntity {
@Column(nullable = false)
public boolean threaded;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
public Visibility visibility;

//

@Transient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public StatusEntity publish(StatusEntity status) {
var data = new HashMap<String, Object>();
data.put("status", status.status);

data.put("visibility", status.group.visibility.toString());

if (status.media != null) {
data.put("media_ids", status.media.stream().map((media) -> media.id).toList());
}
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/de/uoc/dh/idh/autodone/utils/Visibility.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package de.uoc.dh.idh.autodone.utils;

public enum Visibility {
PUBLIC {
@Override
public String toString() {
return "public";
}
},
PRIVATE {
@Override
public String toString() {
return "private";
}
},
UNLISTED {
@Override
public String toString() {
return "unlisted";
}
},
DIRECT {
@Override
public String toString() {
return "direct";
}
}
}
25 changes: 25 additions & 0 deletions src/main/resources/templates/forms/group.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,31 @@
<label class="form-label">Description for the Group</label>
</div>
</div>
<div class="accordion mb-3" id="advanced-options-accordion">
<div class="accordion-item">
<h2 class="accordion-header" id="heading-advanced-options">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-advanced-options" aria-expanded="false" aria-controls="collapse-advanced-options">
Advanced Options
</button>
</h2>
<div id="collapse-advanced-options" class="accordion-collapse collapse" aria-labelledby="heading-advanced-options" data-bs-parent="#advanced-options-accordion">
<div class="row accordion-body">
<div class="col-md-6 mb-3">
<label class="form-label fw-bold" for="visibility">Visibility</label>
<div class="form-floating">
<select th:field="*{visibility}" class="form-select">
<option value="PUBLIC">Public</option>
<option value="PRIVATE">Private</option>
<option value="UNLISTED">Unlisted</option>
<option value="DIRECT">Direct</option>
</select>
<label class="form-label">Visibility of the Group</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="accordion-footer d-flex flex-row-reverse">
<button th:text="*{uuid} ? 'Update' : 'Create'" class="btn btn-outline-primary"></button>
Expand Down