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

CenterForOpenScience / ember-osf-web / 9843787229

08 Jul 2024 04:59PM UTC coverage: 63.097% (-5.0%) from 68.116%
9843787229

push

github

web-flow
Feature/preprints phase 2 (#2261)

* Fix TS variable naming

* Implement is-selected style check/listener

* Add data-test selector

* Clean up css and hbs for mobile

* Disable and grey out the create button when no provider is selected

* Improve naming for CSS classes

* Fix extra spaces in translations/en-us.yml

* CR reponse: improve code quality + use <Button> component

* Initial Step to install a changeset

* Final css change

* Updates for PR comments

* Updates for the pr comments

* Respond to CR pass 2: fix provider fetch query + improve code quality

* Added the updates for the metadata page

* Added the publication year

* Added the publication citation

* Fixed a typo in the field validation

* Added an optional type for the changeset

* Removed the validator for the optional field

* Fix provider filter for `allowSubmissions`

* Update mirage fixtures to allow submissions for all

* Added logic to persist a preprint

* Fixed some issues with the contributors widget

* Added a new user scenario and updates to be able to persist contributors

* Added case insensitivity to the user search

* Added updates to handle adding a contributor to the preprint

* Added the license component ENG-5310

* Updates per the PR

* Fixed some filtering

* Added the licenses acceptable

* Fixed some PR stuff

* Added the tags widget to the metadata page

* Added the subjects widget

* Removed an unnecessary method

* Fixed a copy and paste error

* Updates to the author assertions page to handle the conflict of insterest

* Updates for PR review

* Added backwards compatability for the radio buton group

* Fixed the conflict of interest issue for null

* Minor Updates

* Updates to finalize the radio button form control

* Updates for the PR

* Initial step to add public data

* Another step for public data

* Additional formatting for the radio buttons

* Another ste... (continued)

2650 of 4519 branches covered (58.64%)

Branch coverage included in aggregate %.

44 of 728 new or added lines in 49 files covered. (6.04%)

1 existing line in 1 file now uncovered.

6181 of 9477 relevant lines covered (65.22%)

210.61 hits per line

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

0.0
/lib/osf-components/addon/components/node-picker/component.ts
1
import Component from '@glimmer/component';
2
import Store from '@ember-data/store';
3
import { action } from '@ember/object';
4
import { inject as service } from '@ember/service';
5
import { waitFor } from '@ember/test-waiters';
6
import { restartableTask, timeout } from 'ember-concurrency';
7
import { taskFor } from 'ember-concurrency-ts';
8
import { stripDiacritics } from 'ember-power-select/utils/group-utils';
9
import Node from 'ember-osf-web/models/node';
10
import CurrentUser from 'ember-osf-web/services/current-user';
11
import { tracked } from '@glimmer/tracking';
12

13
function stripAndLower(text: string): string {
NEW
14
    return stripDiacritics(text).toLowerCase();
×
15
}
16

17
/**
18
 * The node picker args
19
 */
20
interface NodePickerArgs {
21
    projectSelected: (value: Node) => void;
22
}
23

24
export default class NodePicker extends Component<NodePickerArgs> {
25
    @service currentUser!: CurrentUser;
26
    @service store!: Store;
27

NEW
28
    @tracked selected: Node | null = null;
×
NEW
29
    filter = '';
×
NEW
30
    page = 1;
×
NEW
31
    @tracked hasMore = false;
×
NEW
32
    @tracked loadingMore = false;
×
NEW
33
    @tracked items: Node[] = [];
×
34

35
    constructor(owner: unknown, args: NodePickerArgs) {
NEW
36
        super(owner, args);
×
37

NEW
38
        this.selected = null;
×
NEW
39
        this.filter = '';
×
NEW
40
        this.page = 1;
×
41

NEW
42
        taskFor(this.findNodes).perform();
×
43
    }
44

45
    @restartableTask
46
    @waitFor
47
    async findNodes(filter = '') {
×
NEW
48
        if (filter) {
×
NEW
49
            await timeout(250);
×
50
        }
51

NEW
52
        const { user } = this.currentUser;
×
53

NEW
54
        if (!user) {
×
NEW
55
            return [];
×
56
        }
57

58
        // If the filter changed, reset the page number
NEW
59
        if (filter !== this.filter) {
×
NEW
60
            this.filter = filter;
×
NEW
61
            this.page = 1;
×
62
        }
63

NEW
64
        const more = this.page > 1;
×
65

NEW
66
        if (more) {
×
NEW
67
            this.loadingMore = true;
×
68
        }
69

NEW
70
        const nodes = await user.queryHasMany('nodes', {
×
71
            filter: {
72
                title: this.filter ? this.filter : undefined,
×
73
            },
74
            page: this.page,
75
        });
76

NEW
77
        const { meta } = nodes;
×
NEW
78
        this.hasMore = meta.total > meta.per_page * this.page;
×
NEW
79
        const items = more ? this.items.concat(nodes) : nodes;
×
80

NEW
81
        this.items = items;
×
NEW
82
        this.loadingMore = false;
×
83

NEW
84
        return items;
×
85
    }
86

87
    /**
88
     * Passed into power-select component for customized searching.
89
     *
90
     * @returns results if match in node, root, or parent title
91
     */
92
    matcher(option: Node, searchTerm: string): -1 | 1 {
NEW
93
        const sanitizedTerm = stripAndLower(searchTerm);
×
94

NEW
95
        const hasTerm = [
×
96
            option.title,
97
            option.root && option.root.title,
×
98
            option.parent && option.parent.title,
×
NEW
99
        ].some(field => !!field && stripAndLower(field).includes(sanitizedTerm));
×
100

NEW
101
        return hasTerm ? 1 : -1;
×
102
    }
103

104
    @action
105
    valueChanged(value?: Node): void {
NEW
106
        if (value) {
×
NEW
107
            this.selected = value;
×
NEW
108
            this.args.projectSelected(value);
×
109
        }
110
    }
111

112
    @action
113
    loadMore(this: NodePicker): Promise<Node[]> {
NEW
114
        this.page += 1;
×
115

NEW
116
        return taskFor(this.findNodes).perform();
×
117
    }
118

119
    @action
120
    oninput(this: NodePicker, term: string): true | Promise<Node[]> {
NEW
121
        return !!term || taskFor(this.findNodes).perform();
×
122
    }
123
}
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