1-
21// The common root-level aspect used in applications like that:
32// using { Attachments } from '@cap-js/attachments'
43aspect Attachments : sap .attachments .Attachments {}
54
6- using { managed , cuid , sap .common .CodeList } from ' @sap/cds/common' ;
5+ using {
6+ managed ,
7+ cuid ,
8+ sap .common .CodeList
9+ } from ' @sap/cds/common' ;
10+
711context sap .attachments {
812
913 aspect MediaData @ (_is_media_data ) {
10- url : String ;
11- content : LargeBinary @ title : ' {i18n>Attachment} ' ; // only for db-based services
12- mimeType : String default ' application/octet-stream' @ title : ' {i18n>MediaType} ' ;
13- filename : String @ title : ' {i18n>FileName} ' ;
14- hash : String @ UI . Hidden @ Core . Computed ;
15- status : String @ title : ' {i18n>ScanStatus} ' default ' Unscanned' @ Common . Text : statusNav .name @ Common . TextArrangement : # TextOnly ;
16- statusNav : Association to one ScanStates on statusNav .code = status ;
14+ url : String @ UI . Hidden ;
15+ content : LargeBinary @ title : ' {i18n>Attachment} ' ; // only for db-based services
16+ mimeType : String default ' application/octet-stream' @ title : ' {i18n>MediaType} ' ;
17+ filename : String @ title : ' {i18n>FileName} ' ;
18+ hash : String @ UI . Hidden @ Core . Computed ;
19+ status : String @ title : ' {i18n>ScanStatus} ' default ' Unscanned' @ Common . Text : statusNav .name @ Common . TextArrangement : # TextOnly ;
20+ statusNav : Association to one ScanStates
21+ on statusNav .code = status ;
1722 }
1823
1924 entity ScanStates : CodeList {
20- key code : String(32) @ Common . Text : name @ Common . TextArrangement : # TextOnly enum {
21- Unscanned ;
22- Scanning ;
23- Infected ;
24- Clean ;
25- Failed ;
26- };
27- name : localized String(64) ;
28- criticality : Integer @ UI . Hidden ;
25+ key code : String(32) @ Common . Text : name @ Common . TextArrangement : # TextOnly enum {
26+ Unscanned ;
27+ Scanning ;
28+ Infected ;
29+ Clean ;
30+ Failed ;
31+ };
32+ name : localized String(64) @ title : ' {i18n>ScanStatus} ' ;
33+ criticality : Integer @ UI . Hidden ;
2934 }
3035
3136 aspect Attachments : cuid , managed , MediaData {
@@ -35,27 +40,46 @@ context sap.attachments {
3540
3641 // -- Fiori Annotations ----------------------------------------------------------
3742
38- annotate MediaData with @ UI . MediaResource : { Stream : content } {
39- content @ Core . MediaType : mimeType @ odata . draft . skip ;
43+ annotate MediaData with @ UI . MediaResource : {Stream : content } {
44+ content @ Core . MediaType : mimeType @ odata . draft . skip ;
4045 mimeType @ Core . IsMediaType ;
41- status @ readonly ;
46+ status @ readonly ;
4247 }
4348
44- annotate Attachments with @ UI : {
49+ annotate Attachments with @ UI : {
4550 HeaderInfo : {
46- TypeName : ' {i18n>Attachment} ' ,
51+ TypeName : ' {i18n>Attachment} ' ,
4752 TypeNamePlural : ' {i18n>Attachments} ' ,
4853 },
49- LineItem : [
50- {Value : content , @ HTML5 . CssDefaults : {width : ' 30% ' }},
51- {Value : status , Criticality : statusNav . criticality , @ HTML5 . CssDefaults : {width : ' 10% ' }},
52- {Value : createdAt , @ HTML5 . CssDefaults : {width : ' 20% ' }},
53- {Value : createdBy , @ HTML5 . CssDefaults : {width : ' 15% ' }},
54- {Value : note , @ HTML5 . CssDefaults : {width : ' 25% ' }}
55- ]
56- } {
54+ LineItem : [
55+ {
56+ Value : content ,
57+ @ HTML5 . CssDefaults : {width : ' 30% ' }
58+ },
59+ {
60+ Value : status ,
61+ Criticality : statusNav . criticality ,
62+ @ HTML5 . CssDefaults : {width : ' 10% ' }
63+ },
64+ {
65+ Value : createdAt ,
66+ @ HTML5 . CssDefaults : {width : ' 20% ' }
67+ },
68+ {
69+ Value : createdBy ,
70+ @ HTML5 . CssDefaults : {width : ' 15% ' }
71+ },
72+ {
73+ Value : note ,
74+ @ HTML5 . CssDefaults : {width : ' 25% ' }
75+ }
76+ ],
77+ } @ Capabilities : {SortRestrictions : {NonSortableProperties : [content ]}} {
5778 content
58- @ Core . ContentDisposition : { Filename : filename , Type : ' inline ' }
79+ @ Core . ContentDisposition : {
80+ Filename : filename ,
81+ Type : ' inline '
82+ }
5983 }
6084
61- }
85+ }
0 commit comments