Просмотр исходного кода

work on #35: display correct chosen visibility

George S. Baugh 5 лет назад
Родитель
Сommit
a79ed3414a
3 измененных файлов с 13 добавлено и 2 удалено
  1. 11 0
      lib/Trog/Data/DUMMY.pm
  2. 1 1
      www/templates/acls.tx
  3. 1 1
      www/templates/series.tx

+ 11 - 0
lib/Trog/Data/DUMMY.pm

@@ -210,6 +210,8 @@ sub get ($self, %request) {
     @filtered = _add_post_type(@filtered);
     # Next, add the type of post this is
     @filtered = _add_media_type(@filtered);
+    # Finally, add visibility
+    @filtered = _add_visibility(@filtered);
 
     return ($pages,\@filtered);
 }
@@ -241,6 +243,15 @@ sub _add_media_type (@posts) {
     } @posts;
 }
 
+sub _add_visibility (@posts) {
+    return map {
+        my $post = $_;
+        my @visibilities = grep { my $tag = $_; grep { $_ eq $tag } qw{private unlisted public} } @{$post->{tags}};
+        $post->{visibility} = $visibilities[0];
+        $post
+    } @posts;
+}
+
 sub add ($self, @posts) {
     require UUID::Tiny;
     foreach my $post (@posts) {

+ 1 - 1
www/templates/acls.tx

@@ -1,7 +1,7 @@
 Visibility<br />
 <select class="cooltext" name="visibility">
     : for $post_visibilities -> $visibility {
-        <option value="<: $visibility :>"><: $visibility :></option>
+        <option <: $post.visibility == $visibility ? 'selected' : '' :> value="<: $visibility :>"><: $visibility :></option>
     : }
 </select>
 ACLs / Series<br/ >

+ 1 - 1
www/templates/series.tx

@@ -5,7 +5,7 @@
     Visibility<br />
     <select class="cooltext" name="visibility">
         : for $post_visibilities -> $visibility {
-            <option value="<: $visibility :>"><: $visibility :></option>
+            <option <: $post.visibility == $visibility ? 'selected' : '' :> value="<: $visibility :>"><: $visibility :></option>
         : }
     </select>
     Comments<br /><textarea class="cooltext" name="comment" placeholder="Potzrebie"><: $post.data :></textarea>