Commit d0580697 authored by lauraMon's avatar lauraMon

Replaces underscore with lodash and vanilla JS

  * Trying vanilla first
parent 0b3b4a59
<script> <script>
import { Sortable, MultiDrag } from 'sortablejs'; import { Sortable, MultiDrag } from 'sortablejs';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import _ from 'underscore';
import boardNewIssue from './board_new_issue.vue'; import boardNewIssue from './board_new_issue.vue';
import boardCard from './board_card.vue'; import boardCard from './board_card.vue';
import eventHub from '../eventhub'; import eventHub from '../eventhub';
...@@ -266,11 +265,12 @@ export default { ...@@ -266,11 +265,12 @@ export default {
* same list or the other list. Don't remove items if it's same list. * same list or the other list. Don't remove items if it's same list.
*/ */
const isSameList = toList && toList.id === this.list.id; const isSameList = toList && toList.id === this.list.id;
if (toList && !isSameList && boardsStore.shouldRemoveIssue(this.list, toList)) { if (toList && !isSameList && boardsStore.shouldRemoveIssue(this.list, toList)) {
const issues = items.map(item => this.list.findIssue(Number(item.dataset.issueId))); const issues = items.map(item => this.list.findIssue(Number(item.dataset.issueId)));
if (
if (_.compact(issues).length && !boardsStore.issuesAreContiguous(this.list, issues)) { issues.filter(Boolean).length &&
!boardsStore.issuesAreContiguous(this.list, issues)
) {
const indexes = []; const indexes = [];
const ids = this.list.issues.map(i => i.id); const ids = this.list.issues.map(i => i.id);
issues.forEach(issue => { issues.forEach(issue => {
......
<script> <script>
import { throttle } from 'underscore'; import { throttle } from 'lodash';
import { import {
GlLoadingIcon, GlLoadingIcon,
GlSearchBoxByType, GlSearchBoxByType,
......
<script> <script>
import _ from 'underscore'; import { sortBy } from 'lodash';
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import { GlLabel, GlTooltipDirective } from '@gitlab/ui'; import { GlLabel, GlTooltipDirective } from '@gitlab/ui';
import issueCardInner from 'ee_else_ce/boards/mixins/issue_card_inner'; import issueCardInner from 'ee_else_ce/boards/mixins/issue_card_inner';
...@@ -100,10 +100,7 @@ export default { ...@@ -100,10 +100,7 @@ export default {
return !groupId ? referencePath.split('#')[0] : null; return !groupId ? referencePath.split('#')[0] : null;
}, },
orderedLabels() { orderedLabels() {
return _.chain(this.issue.labels) return sortBy(this.issue.labels.filter(this.isNonListLabel), 'title');
.filter(this.isNonListLabel)
.sortBy('title')
.value();
}, },
helpLink() { helpLink() {
return boardsStore.scopedLabels.helpLink; return boardsStore.scopedLabels.helpLink;
......
<script> <script>
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { escape } from 'lodash';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -83,7 +83,7 @@ export default { ...@@ -83,7 +83,7 @@ export default {
}" data-project-name="${project.name}" data-project-name-with-namespace="${ }" data-project-name="${project.name}" data-project-name-with-namespace="${
project.name_with_namespace project.name_with_namespace
}"> }">
${_.escape(project.name_with_namespace)} ${escape(project.name_with_namespace)}
</a> </a>
</li> </li>
`; `;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* global List */ /* global List */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { sortBy } from 'lodash';
import Vue from 'vue'; import Vue from 'vue';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import BoardsStoreEE from 'ee_else_ce/boards/stores/boards_store_ee'; import BoardsStoreEE from 'ee_else_ce/boards/stores/boards_store_ee';
...@@ -76,8 +76,7 @@ const boardsStore = { ...@@ -76,8 +76,7 @@ const boardsStore = {
}, },
addList(listObj) { addList(listObj) {
const list = new List(listObj); const list = new List(listObj);
this.state.lists = _.sortBy([...this.state.lists, list], 'position'); this.state.lists = sortBy([...this.state.lists, list], 'position');
return list; return list;
}, },
new(listObj) { new(listObj) {
...@@ -90,7 +89,7 @@ const boardsStore = { ...@@ -90,7 +89,7 @@ const boardsStore = {
// Remove any new issues from the backlog // Remove any new issues from the backlog
// as they will be visible in the new list // as they will be visible in the new list
list.issues.forEach(backlogList.removeIssue.bind(backlogList)); list.issues.forEach(backlogList.removeIssue.bind(backlogList));
this.state.lists = _.sortBy(this.state.lists, 'position'); this.state.lists = sortBy(this.state.lists, 'position');
}) })
.catch(() => { .catch(() => {
// https://gitlab.com/gitlab-org/gitlab-foss/issues/30821 // https://gitlab.com/gitlab-org/gitlab-foss/issues/30821
...@@ -194,10 +193,9 @@ const boardsStore = { ...@@ -194,10 +193,9 @@ const boardsStore = {
moveMultipleIssuesToList({ listFrom, listTo, issues, newIndex }) { moveMultipleIssuesToList({ listFrom, listTo, issues, newIndex }) {
const issueTo = issues.map(issue => listTo.findIssue(issue.id)); const issueTo = issues.map(issue => listTo.findIssue(issue.id));
const issueLists = _.flatten(issues.map(issue => issue.getLists())); const issueLists = issues.map(issue => issue.getLists()).flat();
const listLabels = issueLists.map(list => list.label); const listLabels = issueLists.map(list => list.label);
const hasMoveableIssues = issueTo.filter(Boolean).length > 0;
const hasMoveableIssues = _.compact(issueTo).length > 0;
if (!hasMoveableIssues) { if (!hasMoveableIssues) {
// Check if target list assignee is already present in this issue // Check if target list assignee is already present in this issue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment