@@ -392,7 +392,6 @@ function initialize(api) {
392
392
api . addPostSmallActionIcon ( "unassigned_group" , "group-times" ) ;
393
393
api . addPostSmallActionIcon ( "unassigned_from_post" , "user-xmark" ) ;
394
394
api . addPostSmallActionIcon ( "unassigned_group_from_post" , "group-times" ) ;
395
- api . includePostAttributes ( "assigned_to_user" , "assigned_to_group" ) ;
396
395
api . addPostSmallActionIcon ( "reassigned" , "user-plus" ) ;
397
396
api . addPostSmallActionIcon ( "reassigned_group" , "group-plus" ) ;
398
397
@@ -712,6 +711,30 @@ function initialize(api) {
712
711
}
713
712
714
713
function customizePost ( api ) {
714
+ api . addTrackedPostProperties ( "assigned_to_user" , "assigned_to_group" ) ;
715
+
716
+ api . modifyClass (
717
+ "model:post" ,
718
+ ( Superclass ) =>
719
+ class extends Superclass {
720
+ get can_edit ( ) {
721
+ return isAssignSmallAction ( this . action_code ) ? true : super . can_edit ;
722
+ }
723
+
724
+ // overriding tracked properties requires overriding both the getter and the setter.
725
+ // otherwise the superclass will throw an error when the application sets the field value
726
+ set can_edit ( value ) {
727
+ super . can_edit = value ;
728
+ }
729
+
730
+ get isSmallAction ( ) {
731
+ return isAssignSmallAction ( this . action_code )
732
+ ? true
733
+ : super . isSmallAction ;
734
+ }
735
+ }
736
+ ) ;
737
+
715
738
api . renderAfterWrapperOutlet (
716
739
"post-content-cooked-html" ,
717
740
PostAssignmentsDisplay
@@ -872,33 +895,34 @@ function customizeWidgetPost(api) {
872
895
} ,
873
896
} ) ;
874
897
875
- // This won't have a direct translation in the Glimmer API as it uses can_edit from the model
876
- // TODO (glimmer-post-stream): check the post small action component and introduce a transformer to override the
877
- // canEdit behavior there
898
+ // `addPostTransformCallback` doesn't have a direct translation in the new Glimmer API.
899
+ // We need to use a modify class in the post model instead
878
900
api . addPostTransformCallback ( ( transformed ) => {
879
- if (
880
- [
881
- "assigned" ,
882
- "unassigned" ,
883
- "reassigned" ,
884
- "assigned_group" ,
885
- "unassigned_group" ,
886
- "reassigned_group" ,
887
- "assigned_to_post" ,
888
- "assigned_group_to_post" ,
889
- "unassigned_from_post" ,
890
- "unassigned_group_from_post" ,
891
- "details_change" ,
892
- "note_change" ,
893
- "status_change" ,
894
- ] . includes ( transformed . actionCode )
895
- ) {
901
+ if ( isAssignSmallAction ( transformed . actionCode ) ) {
896
902
transformed . isSmallAction = true ;
897
903
transformed . canEdit = true ;
898
904
}
899
905
} ) ;
900
906
}
901
907
908
+ function isAssignSmallAction ( actionCode ) {
909
+ return [
910
+ "assigned" ,
911
+ "unassigned" ,
912
+ "reassigned" ,
913
+ "assigned_group" ,
914
+ "unassigned_group" ,
915
+ "reassigned_group" ,
916
+ "assigned_to_post" ,
917
+ "assigned_group_to_post" ,
918
+ "unassigned_from_post" ,
919
+ "unassigned_group_from_post" ,
920
+ "details_change" ,
921
+ "note_change" ,
922
+ "status_change" ,
923
+ ] . includes ( actionCode ) ;
924
+ }
925
+
902
926
function customizePostMenu ( api ) {
903
927
api . registerValueTransformer (
904
928
"post-menu-buttons" ,
0 commit comments