• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CenterForOpenScience / ember-osf-web / 5543708847

pending completion
5543708847

push

github

web-flow
Merge pull request #1904 from CenterForOpenScience/basket/cesium

Basket/cesium

2490 of 3649 branches covered (68.24%)

Branch coverage included in aggregate %.

101 of 101 new or added lines in 25 files covered. (100.0%)

5711 of 7667 relevant lines covered (74.49%)

244.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.63
/app/guid-node/registrations/controller.ts
1
import Store from '@ember-data/store';
2
import Controller from '@ember/controller';
3
import { assert } from '@ember/debug';
4
import { action, computed } from '@ember/object';
5
import { alias } from '@ember/object/computed';
6
import { inject as service } from '@ember/service';
7
import { waitFor } from '@ember/test-waiters';
8
import { task } from 'ember-concurrency';
9
import config from 'ember-get-config';
10
import Media from 'ember-responsive';
11

12
import Node from 'ember-osf-web/models/node';
13
import RegistrationSchema from 'ember-osf-web/models/registration-schema';
14
import Analytics from 'ember-osf-web/services/analytics';
15

16
export default class GuidNodeRegistrations extends Controller {
17
    @service media!: Media;
18
    @service analytics!: Analytics;
19
    @service store!: Store;
20

21
    queryParams = ['tab'];
14✔
22
    tab?: string;
23

24
    draftsQueryParams = { embed: ['initiator', 'registration_schema', 'branched_from', 'provider'] };
14✔
25
    defaultSchema!: RegistrationSchema;
26
    selectedSchema!: RegistrationSchema;
27
    schemas: RegistrationSchema[] = [];
14✔
28
    newModalOpen = false;
14✔
29

30
    reloadDrafts?: (page?: number) => void; // bound by paginated-list
31

32
    @alias('model.taskInstance.value') node!: Node | null;
33

34
    @task
35
    @waitFor
36
    async getRegistrationSchemas() {
37
        const { defaultProvider } = config;
13✔
38
        const provider = await this.store.findRecord(
13✔
39
            'registration-provider',
40
            defaultProvider,
41
        );
42
        let schemas: RegistrationSchema[] = await provider.loadAll('schemas');
13✔
43
        schemas = schemas.toArray();
13✔
44
        schemas.sort((a: RegistrationSchema, b: RegistrationSchema) => a.name.length - b.name.length);
26✔
45
        this.set('defaultSchema', schemas.firstObject);
13✔
46
        this.set('selectedSchema', this.defaultSchema);
13✔
47
        this.set('schemas', schemas);
13✔
48
    }
49

50
    @computed('node.{id,root.id,root.userHasAdminPermission}')
51
    get isComponentRootAdmin() {
52
        return this.node && this.node.id !== this.node.root.get('id') && this.node.root.get('userHasAdminPermission');
18!
53
    }
54

55
    @action
56
    changeTab(activeId: number) {
57
        const tabName = activeId === 0 ? 'registrations' : 'drafts';
7!
58
        this.analytics.click('tab', `Registrations tab - Change tab to: ${tabName}`);
7✔
59
    }
60

61
    @action
62
    closeNewModal() {
63
        this.set('newModalOpen', false);
1✔
64
        this.set('selectedSchema', this.defaultSchema);
1✔
65
    }
66

67
    @action
68
    schemaChanged(schema: RegistrationSchema) {
69
        this.set('selectedSchema', schema);
×
70
        this.analytics.click('radio', `Registrations tab - Select schema: ${schema.name}`);
×
71
    }
72

73
    @action
74
    async createDraft() {
75
        const branchedFrom = this.node!;
×
76
        assert('Check that the node exists', Boolean(branchedFrom));
×
77

78
        const draftRegistration = this.store.createRecord('draft-registration', {
×
79
            registrationSupplement: this.selectedSchema.id,
80
            branchedFrom,
81
            registrationSchema: this.selectedSchema,
82
        });
83
        await draftRegistration.save();
×
84
        this.set('newModalOpen', false);
×
85
        this.set('selectedSchema', this.defaultSchema);
×
86

87
        this.transitionToRoute(
×
88
            'guid-node.drafts',
89
            branchedFrom.id,
90
            draftRegistration.id,
91
        );
92
    }
93

94
    get isMobile() {
95
        return this.media.isMobile;
13✔
96
    }
97
}
98

99
declare module '@ember/controller' {
100
    interface Registry {
101
        'guid-node/registrations': GuidNodeRegistrations;
102
    }
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc