Skip to content

Commit 8eb8505

Browse files
committed
Merge branch 'multi-level-bug' of https://github.com/cap-js/attachments into multi-level-bug
Merge
2 parents ebde99f + 0bf95e4 commit 8eb8505

File tree

2 files changed

+72
-59
lines changed

2 files changed

+72
-59
lines changed

db/index.cds

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
1-
21
// The common root-level aspect used in applications like that:
32
// using { Attachments } from '@cap-js/attachments'
43
aspect 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+
711
context 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+
}
Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,35 @@
1-
2-
using { sap.capire.incidents as my } from './schema';
3-
using { Attachments } from '@cap-js/attachments';
1+
using {sap.capire.incidents as my} from './schema';
2+
using {Attachments} from '@cap-js/attachments';
43

54
extend my.Incidents with {
6-
attachments: Composition of many Attachments;
5+
attachments : Composition of many Attachments;
76
@attachments.disable_facet
8-
hiddenAttachments: Composition of many Attachments;
7+
hiddenAttachments : Composition of many Attachments;
98

109
@UI.Hidden
11-
hiddenAttachments2: Composition of many Attachments;
10+
hiddenAttachments2 : Composition of many Attachments;
1211

1312
@UI.Hidden
14-
mediaTypeAttachments: Composition of many Attachments;
13+
mediaTypeAttachments : Composition of many Attachments;
1514
}
1615

1716
annotate my.Incidents.hiddenAttachments with {
18-
content @Validation.Maximum : '2MB';
17+
content @Validation.Maximum: '2MB';
1918
}
2019

2120
annotate my.Incidents.mediaTypeAttachments with {
22-
content @Core.AcceptableMediaTypes : ['image/jpeg'];
21+
content @Core.AcceptableMediaTypes: ['image/jpeg'];
2322
}
2423

25-
@UI.Facets : [
26-
{
27-
$Type : 'UI.ReferenceFacet',
28-
Target : 'attachments/@UI.LineItem',
29-
Label : 'My custom attachments',
30-
}
31-
]
24+
@UI.Facets: [{
25+
$Type : 'UI.ReferenceFacet',
26+
Target: 'attachments/@UI.LineItem',
27+
Label : 'My custom attachments',
28+
}]
3229
extend my.Customers with {
33-
attachments: Composition of many Attachments;
30+
attachments : Composition of many Attachments;
3431
}
3532

3633
extend my.SampleRootWithComposedEntity with {
37-
attachments: Composition of many Attachments;
38-
}
39-
40-
extend my.Test with {
41-
attachments: Composition of many Attachments;
34+
attachments : Composition of many Attachments;
4235
}
43-
44-
extend my.TestDetails with {
45-
attachments: Composition of many Attachments;
46-
}

0 commit comments

Comments
 (0)