Skip to content
This repository was archived by the owner on Feb 28, 2023. It is now read-only.

File Uploader #80

Merged
merged 37 commits into from
Feb 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
63d8a8c
Merge branch 'release-1.0.0-beta.6'
simardo Dec 18, 2017
9b1174d
Merge branch 'release-1.0.0-beta.7'
simardo Dec 20, 2017
54a9747
Merge branch 'release-1.0.0-beta.8'
simardo Jan 10, 2018
49ed1c6
Merge branch 'release-1.0.0-beta.9'
simardo Jan 12, 2018
221caac
Merge branch 'release-1.0.0-beta.10'
simardo Jan 15, 2018
d52f256
Merge branch 'release-1.0.0-beta.11'
simardo Jan 23, 2018
22f0151
Merge branch 'release-1.0.0-beta.12'
simardo Jan 23, 2018
961b342
Merge branch 'release-1.0.0-beta.13'
simardo Jan 25, 2018
54c4351
Merge branch 'release-1.0.0-beta.14'
simardo Jan 30, 2018
d144b67
Merge branch 'release-1.0.0-beta.15'
simardo Jan 30, 2018
c85326b
Merge branch 'release-1.0.0-beta.16'
simardo Feb 5, 2018
17bf7d1
Merge branch 'release-1.0.0-beta.17'
simardo Feb 6, 2018
f2cddb5
Merge pull request #71 from ulaval/release-1.0.0-beta.18
simardo Feb 14, 2018
30482ae
file-select
jfnadeau Feb 19, 2018
74646e6
$file
jfnadeau Feb 19, 2018
7cb8655
file-upload
jfnadeau Feb 19, 2018
7badd09
progress
jfnadeau Feb 19, 2018
f626679
file-drop
jfnadeau Feb 19, 2018
8c1321b
drag-drop zone vector
jfnadeau Feb 19, 2018
509fd32
filesize dependency
jfnadeau Feb 19, 2018
0fe4f44
spec to jest
jfnadeau Feb 19, 2018
2c6eadd
file extension to method
jfnadeau Feb 19, 2018
9d4ca1f
Add error message under the progress bar
setur52 Feb 19, 2018
be9c418
visual hint after file is completed
jfnadeau Feb 19, 2018
47ff545
remove setTimeout
jfnadeau Feb 19, 2018
3276840
translation filesize
jfnadeau Feb 19, 2018
016d86f
file-upload spec
jfnadeau Feb 20, 2018
bf61e43
extract file mocking utils
jfnadeau Feb 20, 2018
00965a9
Style modifications
setur52 Feb 20, 2018
3140a3a
update shapshot
setur52 Feb 20, 2018
f937985
meta: support optional prop
jfnadeau Feb 21, 2018
7c0df37
line break
jfnadeau Feb 21, 2018
e33ecc0
extra typing
jfnadeau Feb 21, 2018
0ac1012
extension - convert to getter
jfnadeau Feb 21, 2018
9b26355
Typing getters
setur52 Feb 21, 2018
f4367fb
Merge branch 'feature/fileupload' of https://github.com/ulaval/modul-…
simardo Feb 22, 2018
6638f5e
update package-lock (to resolve conflict)
simardo Feb 22, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,032 changes: 621 additions & 411 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"css-loader": "^0.28.7",
"enquire.js": "^2.1.6",
"file-loader": "^1.1.5",
"filesize": "^3.6.0",
"moment": "^2.19.3",
"node-sass": "^4.7.2",
"popper.js": "^1.12.9",
Expand All @@ -76,9 +77,11 @@
},
"devDependencies": {
"@types/es6-promise": "^0.0.33",
"@types/filesize": "^3.6.0",
"@types/jest": "^22.1.1",
"@types/node": "^8.0.54",
"@vue/test-utils": "^1.0.0-beta.11",
"ajv": "^6.1.1",
"awesome-typescript-loader": "^3.4.1",
"axios": "^0.17.1",
"bundle-loader": "^0.5.5",
Expand All @@ -90,6 +93,7 @@
"enquire.js": "^2.1.6",
"es6-promise": "^4.1.1",
"file-loader": "^1.1.5",
"filesize": "^3.6.0",
"html-webpack-plugin": "^2.30.1",
"jest": "^22.1.4",
"jest-junit": "^3.6.0",
Expand All @@ -98,7 +102,7 @@
"nightwatch": "^0.9.19",
"node-sass": "^4.7.2",
"popper.js": "^1.12.9",
"portal-vue": "^1.1.1",
"portal-vue": "~1.1.1",
"postcss-loader": "^2.0.9",
"postcss-sass": "^0.2.0",
"qs": "^6.5.1",
Expand Down
38 changes: 38 additions & 0 deletions src/assets/icons/sprites-default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/components/component-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const DROPDOWN_NAME: string = 'm-dropdown';
export const DROPDOWN_ITEM_NAME: string = 'm-dropdown-item';
export const DROPDOWN_GROUP_NAME: string = 'm-dropdown-group';
export const DYNAMIC_TEMPLATE_NAME: string = 'm-dynamic-template';
export const FILE_SELECT_NAME: string = 'm-file-select';
export const FILE_UPLOAD_NAME: string = 'm-file-upload';
export const EDIT_WINDOW_NAME: string = 'm-edit-window';
export const FLEX_TEMPLATE_NAME: string = 'm-flex-template';
export const I18N_NAME: string = 'm-i18n';
Expand All @@ -31,6 +33,7 @@ export const PANEL_NAME: string = 'm-panel';
export const PHONE_NUMBER_NAME: string = 'm-phone-number';
export const POPPER_NAME: string = 'm-popper';
export const POPUP_NAME: string = 'm-popup';
export const PROGRESS_NAME: string = 'm-progress';
export const RADIO_NAME: string = 'm-radio';
export const RADIO_GROUP_NAME: string = 'm-radio-group';
export const RADIO_STYLE_NAME: string = 'm-radio-style';
Expand Down
17 changes: 9 additions & 8 deletions src/components/dialog/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { ModulVue } from '../../utils/vue/vue';
import { PluginObject } from 'vue';
import Component from 'vue-class-component';
import WithRender from './dialog.html?style=./dialog.scss';
import { Prop } from 'vue-property-decorator';
import { DIALOG_NAME } from '../component-names';
import { Portal, PortalMixin, PortalMixinImpl, BackdropMode, PortalTransitionDuration } from '../../mixins/portal/portal';

import { MediaQueriesMixin } from '../../mixins/media-queries/media-queries';
import { BackdropMode, Portal, PortalMixin, PortalMixinImpl, PortalTransitionDuration } from '../../mixins/portal/portal';
import { ModulVue } from '../../utils/vue/vue';
import { DIALOG_NAME } from '../component-names';
import WithRender from './dialog.html?style=./dialog.scss';

export enum MDialogSize {
FullScreen = 'full-screen',
Expand Down Expand Up @@ -45,6 +46,10 @@ export class MDialog extends ModulVue implements PortalMixinImpl {
@Prop({ default: true })
public paddingFooter: boolean;

public closeDialog(): void {
this.as<PortalMixin>().tryClose();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La mécanique de close des modals a évolué depuis... Est-ce qu'on a validé que ça fonctionnait bien dans le cas où le téléverseur pop à partir d'une fenêtre modale? Et surtout que la fermeture s'effectue correctement lorsqu'on clique sur le backdrop par exemple.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai testé le téléverser dans une fenêtre modale et ça fonctionne. Pour le clic sur l'arrière-plan, j'ai mis l'option à false, je vais valider si c'est un comportement qu'on souhaite.

}

public handlesFocus(): boolean {
return true;
}
Expand Down Expand Up @@ -102,10 +107,6 @@ export class MDialog extends ModulVue implements PortalMixinImpl {
this.as<PortalMixin>().tryClose();
}
}

private closeDialog(): void {
this.as<PortalMixin>().tryClose();
}
}

const DialogPlugin: PluginObject<any> = {
Expand Down
10 changes: 10 additions & 0 deletions src/components/file-select/__snapshots__/file-select.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`file-select should render correctly 1`] = `
<div class="m-file-select">
<input type="file" id="mFileSelect-uuid" tabindex="-1" class="m-file-select__hidden">
<label for="mFileSelect-uuid" class="m-file-select__hidden"><span class="m-i18n">Browse</span></label>
<button type="button" aria-hidden="true" class="m-button m--is-skin-secondary"> <span class="m-button__text"><span class="m-i18n">Browse</span> </span>
</button>
</div>
`;
24 changes: 24 additions & 0 deletions src/components/file-select/file-select.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="m-file-select">
<input ref="inputFile" type="file" :id="id" class="m-file-select__hidden" @change="processFile" :disabled="disabled || isWaiting" tabindex="-1" :multiple="multiple">
<label :for="id" class="m-file-select__hidden">
<m-i18n v-if="!hasLabel" k="m-select-file:label"></m-i18n>
<template v-else>{{ label }}</template>
</label>
<m-button @click="onClick" @focus="onFocus" @blur="onBlur" aria-hidden="true"
:skin="skin"
:disabled="disabled"
:waiting="waiting"
:fullSize="fullSize"
:iconName="iconName"
:iconPosition="iconPosition"
:iconSize="iconSize">
<m-i18n v-if="!hasLabel" k="m-select-file:label"></m-i18n>
<template v-else>{{ label }}</template>
</m-button>
<m-validation-message ref="validation"
:disabled="isDisabled"
:error="hasError"
:error-message="errorMessage"
:valid-message="validMessage"
:helper-message="helperMessage"></m-validation-message>
</div>
5 changes: 5 additions & 0 deletions src/components/file-select/file-select.lang.en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"m-select-file": {
"label": "Browse"
}
}
5 changes: 5 additions & 0 deletions src/components/file-select/file-select.lang.fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"m-select-file": {
"label": "Parcourir"
}
}
7 changes: 7 additions & 0 deletions src/components/file-select/file-select.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import 'abstracts/variables';

.m-file-select {
&__hidden {
@include m-visually-hidden;
}
}
79 changes: 79 additions & 0 deletions src/components/file-select/file-select.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { createLocalVue, mount } from '@vue/test-utils';
import Vue, { VueConstructor } from 'vue';

import { addMessages } from '../../../tests/helpers/lang';
import { renderComponent } from '../../../tests/helpers/render';
import uuid from '../../utils/uuid/uuid';
import { MButton } from '../button/button';
import FileSelectPlugin, { MFileSelect } from './file-select';

jest.mock('../../utils/uuid/uuid');
(uuid.generate as jest.Mock).mockReturnValue('uuid');

describe('file-select', () => {
let localVue: VueConstructor<Vue>;

beforeEach(() => {
localVue = createLocalVue();
localVue.use(FileSelectPlugin);
addMessages(localVue, [
'components/file-select/file-select.lang.en.json',
'components/validation-message/validation-message.lang.en.json'
]);
});

it('should render correctly', () => {
const fileSelect = mount(MFileSelect, {
localVue: localVue
});

return expect(
renderComponent(fileSelect.vm)
).resolves.toMatchSnapshot();
});

it('should flow down button props', () => {
const buttonProps = {
skin: 'primary',
disabled: true,
waiting: true,
fullSize: true,
iconName: 'icon-name',
iconPosition: 'right',
iconSize: '24px'
};

const fileSelect = mount(MFileSelect, {
localVue: localVue,
propsData: buttonProps
});

expect(fileSelect.find(MButton).props()).toEqual(buttonProps);
});

it('should set multiple attribute on input based on prop value', () => {
const fileSelect = mount(MFileSelect, {
localVue: localVue
});

fileSelect.setProps({ multiple: true });
expect(fileSelect.find('input').attributes()).toHaveProperty(
'multiple'
);

fileSelect.setProps({ multiple: false });
expect(fileSelect.find('input').attributes()).not.toHaveProperty(
'multiple'
);
});

it('should emit click event when button is clicked', () => {
const fileSelect = mount(MFileSelect, {
localVue: localVue
});

fileSelect.find(MButton).trigger('click');

expect(fileSelect.emitted('click')).toBeTruthy();
});
});
Loading