Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.1] Corrected different multi-select behavior in media manager. #39824

Open
wants to merge 25 commits into
base: 5.1-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3af0f02
multiselect
rajputanuj31 Feb 8, 2023
6d6bac9
Merge branch 'joomla:4.2-dev' into multi-select
rajputanuj31 Feb 8, 2023
96f16ac
Revert "Improving the consistency of the HTML models (#39715)"
rajputanuj31 Feb 8, 2023
981522f
updates
rajputanuj31 Feb 8, 2023
869b168
updates
rajputanuj31 Feb 8, 2023
a901214
updates
rajputanuj31 Feb 9, 2023
52e7d7d
updates
rajputanuj31 Feb 9, 2023
cabe3cc
comments updated
rajputanuj31 Feb 10, 2023
e4a509f
fixed a typo in comments
rajputanuj31 Feb 10, 2023
005b0d6
updates
rajputanuj31 Feb 10, 2023
831630a
updates
rajputanuj31 Feb 10, 2023
adbc92c
updates
rajputanuj31 Feb 10, 2023
da552d8
updates
rajputanuj31 Feb 10, 2023
30dd2da
ci-error
rajputanuj31 Feb 10, 2023
1e6ee56
updates
rajputanuj31 Feb 10, 2023
7616a50
Update administrator/components/com_media/resources/scripts/component…
rajputanuj31 Feb 10, 2023
e4dfbca
Update administrator/components/com_media/resources/scripts/component…
rajputanuj31 Feb 10, 2023
15a31ad
Merge branch '4.3-dev' into multi-select
rajputanuj31 Feb 11, 2023
a6340d8
Merge branch '4.3-dev' into multi-select
Quy Feb 16, 2023
61f4441
Update utils.es6.js
rajputanuj31 Feb 17, 2023
dff326b
Update utils.es6.js
rajputanuj31 Feb 17, 2023
9dfae97
Update administrator/components/com_media/resources/scripts/component…
rajputanuj31 Feb 17, 2023
7f3ca0d
Merge branch '4.3-dev' into multi-select
rajputanuj31 Feb 17, 2023
092b9de
Merge branch '4.3-dev' into multi-select
rajputanuj31 Mar 9, 2023
f971327
Merge branch '4.3-dev' into multi-select
rajputanuj31 Mar 24, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
v-for="item in localItems"
:key="item.path"
:item="item"
:localItems="localItems"
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import Image from './image.vue';
import Video from './video.vue';
import Audio from './audio.vue';
import Doc from './document.vue';
import * as types from '../../../store/mutation-types.es6';
import api from '../../../app/Api.es6';
import onItemClick from '../utils/utils.es6';

export default {
props: {
item: {
type: Object,
default: () => {},
},
localItems: {
type: Array,
default: () => [],
},
},
data() {
return {
Expand Down Expand Up @@ -120,58 +124,7 @@ export default {
* @param event
*/
rajputanuj31 marked this conversation as resolved.
Show resolved Hide resolved
handleClick(event) {
if (this.item.path && this.item.type === 'file') {
window.parent.document.dispatchEvent(
new CustomEvent('onMediaFileSelected', {
bubbles: true,
cancelable: false,
detail: {
path: this.item.path,
thumb: this.item.thumb,
fileType: this.item.mime_type ? this.item.mime_type : false,
extension: this.item.extension ? this.item.extension : false,
width: this.item.width ? this.item.width : 0,
height: this.item.height ? this.item.height : 0,
},
}),
);
}

if (this.item.type === 'dir') {
window.parent.document.dispatchEvent(
new CustomEvent('onMediaFileSelected', {
bubbles: true,
cancelable: false,
detail: {},
}),
);
}

// Handle clicks when the item was not selected
if (!this.isSelected()) {
// Unselect all other selected items,
// if the shift key was not pressed during the click event
if (!(event.shiftKey || event.keyCode === 13)) {
this.$store.commit(types.UNSELECT_ALL_BROWSER_ITEMS);
}
this.$store.commit(types.SELECT_BROWSER_ITEM, this.item);
return;
}
this.$store.dispatch('toggleBrowserItemSelect', this.item);
window.parent.document.dispatchEvent(
new CustomEvent('onMediaFileSelected', {
bubbles: true,
cancelable: false,
detail: {},
}),
);

// If more than one item was selected and the user clicks again on the selected item,
// he most probably wants to unselect all other items.
if (this.$store.state.selectedItems.length > 1) {
this.$store.commit(types.UNSELECT_ALL_BROWSER_ITEMS);
this.$store.commit(types.SELECT_BROWSER_ITEM, this.item);
}
return onItemClick(event, this);
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<script>
import * as types from '../../../store/mutation-types.es6';
import navigable from '../../../mixins/navigable.es6';
import onItemClick from '../utils/utils.es6';

export default {
name: 'MediaBrowserItemRow',
Expand All @@ -42,6 +43,10 @@ export default {
type: Object,
default: () => {},
},
localItems: {
type: Array,
default: () => [],
},
},
computed: {
/* The dimension of a file */
Expand Down Expand Up @@ -98,49 +103,7 @@ export default {
* @param event
*/
rajputanuj31 marked this conversation as resolved.
Show resolved Hide resolved
onClick(event) {
const path = false;
const data = {
path,
thumb: false,
fileType: this.item.mime_type ? this.item.mime_type : false,
extension: this.item.extension ? this.item.extension : false,
};

if (this.item.type === 'file') {
data.path = this.item.path;
data.thumb = this.item.thumb ? this.item.thumb : false;
data.width = this.item.width ? this.item.width : 0;
data.height = this.item.height ? this.item.height : 0;

window.parent.document.dispatchEvent(
new CustomEvent(
'onMediaFileSelected',
{
bubbles: true,
cancelable: false,
detail: data,
},
),
);
}

// Handle clicks when the item was not selected
if (!this.isSelected()) {
// Unselect all other selected items,
// if the shift key was not pressed during the click event
if (!(event.shiftKey || event.keyCode === 13)) {
this.$store.commit(types.UNSELECT_ALL_BROWSER_ITEMS);
}
this.$store.commit(types.SELECT_BROWSER_ITEM, this.item);
return;
}

// If more than one item was selected and the user clicks again on the selected item,
// he most probably wants to unselect all other items.
if (this.$store.state.selectedItems.length > 1) {
this.$store.commit(types.UNSELECT_ALL_BROWSER_ITEMS);
this.$store.commit(types.SELECT_BROWSER_ITEM, this.item);
}
return onItemClick(event, this);
},

},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
v-for="item in localItems"
:key="item.path"
:item="item"
:local-items="localItems"
/>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import * as types from '../../../store/mutation-types.es6';
rajputanuj31 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Handle the click event
* @param event
* @param ctx the context
*/
export default function onItemClick(event, ctx) {
if (ctx.item.path && ctx.item.type === 'file') {
window.parent.document.dispatchEvent(
new CustomEvent('onMediaFileSelected', {
bubbles: true,
cancelable: false,
detail: {
path: ctx.item.path,
thumb: ctx.item.thumb,
fileType: ctx.item.mime_type ? ctx.item.mime_type : false,
extension: ctx.item.extension ? ctx.item.extension : false,
width: ctx.item.width ? ctx.item.width : 0,
height: ctx.item.height ? ctx.item.height : 0,
},
}),
);
}

if (ctx.item.type === 'dir') {
window.parent.document.dispatchEvent(
new CustomEvent('onMediaFileSelected', {
bubbles: true,
cancelable: false,
detail: {},
}),
);
}

// Handle clicks when the item was not selected
if (!ctx.isSelected()) {
rajputanuj31 marked this conversation as resolved.
Show resolved Hide resolved
// Handle clicks when shift key was pressed
if (event.shiftKey || event.keyCode === 13) {
const currentIndex = ctx.localItems.indexOf(ctx.$store.state.selectedItems[0]);
const endindex = ctx.localItems.indexOf(ctx.item);
// Handle selections from up to down
if (currentIndex < endindex) {
ctx.localItems.slice(currentIndex, endindex + 1)
.forEach((element) => ctx.$store.commit(types.SELECT_BROWSER_ITEM, element));
// Handle selections from down to up
} else {
ctx.localItems.slice(endindex, currentIndex)
.forEach((element) => ctx.$store.commit(types.SELECT_BROWSER_ITEM, element));
}
// Handle clicks when ctrl key was pressed
} else if (event[/Mac|Mac OS|MacIntel/gi.test(window.navigator.userAgent) ? 'metaKey' : 'ctrlKey'] || event.keyCode === 17) {
ctx.$store.commit(types.SELECT_BROWSER_ITEM, ctx.item);
} else {
ctx.$store.commit(types.UNSELECT_ALL_BROWSER_ITEMS);
ctx.$store.commit(types.SELECT_BROWSER_ITEM, ctx.item);
}
return;
}
rajputanuj31 marked this conversation as resolved.
Show resolved Hide resolved
ctx.$store.dispatch('toggleBrowserItemSelect', ctx.item);
window.parent.document.dispatchEvent(
new CustomEvent('onMediaFileSelected', {
bubbles: true,
cancelable: false,
detail: {},
}),
);

// If more than one item was selected and the user clicks again on the selected item,
// he most probably wants to unselect all other items.
if (ctx.$store.state.selectedItems.length > 1) {
ctx.$store.commit(types.UNSELECT_ALL_BROWSER_ITEMS);
ctx.$store.commit(types.SELECT_BROWSER_ITEM, ctx.item);
}
}