forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/tags' into develop
# Conflicts: # app/models/server/models/Messages.js # app/models/server/raw/index.js # app/theme/client/main.css # client/importPackages.js # server/importPackages.js
- Loading branch information
Showing
48 changed files
with
1,527 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Tags } from '../../../models/server/raw'; | ||
|
||
export async function findTags({ query = {}, pagination: { offset, count, sort } }) { | ||
const cursor = await Tags.find(query, { | ||
sort: sort || { name: 1 }, | ||
skip: offset, | ||
limit: count, | ||
}); | ||
|
||
const total = await cursor.count(); | ||
|
||
const tags = await cursor.toArray(); | ||
|
||
return { | ||
tags, | ||
count: tags.length, | ||
offset, | ||
total, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { API } from '../api'; | ||
import { findTags } from '../lib/tags'; | ||
|
||
API.v1.addRoute('tags.list', { authRequired: true }, { | ||
get() { | ||
const { offset, count } = this.getPaginationItems(); | ||
const { sort, query } = this.parseJsonQuery(); | ||
|
||
return API.v1.success(Promise.await(findTags({ | ||
query, | ||
pagination: { | ||
offset, | ||
count, | ||
sort, | ||
}, | ||
}))); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Base } from './_Base'; | ||
|
||
export class Tags extends Base { | ||
constructor() { | ||
super('tags'); | ||
|
||
this.tryEnsureIndex({ name: 1 }); | ||
} | ||
|
||
findOneById(_id, options) { | ||
return this.findOne(_id, options); | ||
} | ||
|
||
findByName(name, options) { | ||
const query = { | ||
name, | ||
}; | ||
|
||
return this.find(query, options); | ||
} | ||
|
||
findByNameExceptId(name, except, options) { | ||
const query = { | ||
_id: { $nin: [except] }, | ||
name, | ||
}; | ||
|
||
return this.find(query, options); | ||
} | ||
|
||
// INSERT | ||
create(data) { | ||
return this.insert(data); | ||
} | ||
|
||
// update | ||
setName(_id, name) { | ||
const update = { | ||
$set: { | ||
name, | ||
}, | ||
}; | ||
|
||
return this.update({ _id }, update); | ||
} | ||
|
||
// REMOVE | ||
removeById(_id) { | ||
return this.remove(_id); | ||
} | ||
} | ||
|
||
export default new Tags(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { BaseRaw } from './BaseRaw'; | ||
|
||
export class TagsRaw extends BaseRaw { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
& .reactions { | ||
margin-top: 4px; | ||
padding: 0; | ||
display: inline-block; | ||
|
||
& > li { | ||
position: relative; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import './tagPicker'; | ||
import { TagPicker } from './lib/TagPicker'; | ||
|
||
export { | ||
TagPicker, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import _ from 'underscore'; | ||
import { Blaze } from 'meteor/blaze'; | ||
import { Template } from 'meteor/templating'; | ||
|
||
export const TagPicker = { | ||
width: 365, | ||
height: 300, | ||
initiated: false, | ||
input: null, | ||
source: null, | ||
opened: false, | ||
pickCallback: null, | ||
scrolling: false, | ||
async init() { | ||
if (this.initiated) { | ||
return; | ||
} | ||
|
||
this.initiated = true; | ||
|
||
Blaze.render(Template.tagPicker, document.body); | ||
|
||
$(document).click((event) => { | ||
if (!this.opened) { | ||
return; | ||
} | ||
if (!$(event.target).closest('.tag-picker').length && !$(event.target).is('.tag-picker')) { | ||
if (this.opened) { | ||
this.close(); | ||
} | ||
} | ||
}); | ||
|
||
$(window).resize(_.debounce(() => { | ||
if (!this.opened) { | ||
return; | ||
} | ||
this.setPosition(); | ||
}, 300)); | ||
}, | ||
isOpened() { | ||
return this.opened; | ||
}, | ||
setPosition() { | ||
const windowHeight = window.innerHeight; | ||
const windowWidth = window.innerWidth; | ||
const windowBorder = 10; | ||
const sourcePos = $(this.source).offset(); | ||
const {left, top} = sourcePos; | ||
const cssProperties = {top, left}; | ||
const isLargerThanWindow = this.width + windowBorder > windowWidth; | ||
|
||
if (top + this.height >= windowHeight) { | ||
cssProperties.top = windowHeight - this.height - windowBorder - 75; | ||
} | ||
|
||
if (left < windowBorder) { | ||
cssProperties.left = isLargerThanWindow ? 0 : windowBorder; | ||
} | ||
|
||
if (left + this.width >= windowWidth) { | ||
cssProperties.left = isLargerThanWindow ? 0 : windowWidth - this.width - windowBorder; | ||
} | ||
|
||
return $('.tag-picker').css(cssProperties); | ||
}, | ||
async open(source, callback) { | ||
if (!this.initiated) { | ||
await this.init(); | ||
} | ||
this.pickCallback = callback; | ||
this.source = source; | ||
|
||
const containerEl = this.setPosition(); | ||
containerEl.addClass('show'); | ||
|
||
const tagInput = containerEl.find('.js-tagpicker-search'); | ||
if (tagInput) { | ||
tagInput.focus(); | ||
} | ||
|
||
this.opened = true; | ||
}, | ||
close() { | ||
$('.tag-picker').removeClass('show'); | ||
this.opened = false; | ||
this.source.focus(); | ||
}, | ||
pickTag(tag) { | ||
this.pickCallback(tag); | ||
|
||
this.close(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<template name="tagPicker"> | ||
<div class="tag-picker rc-popover__content"> | ||
<div class="tag-top"> | ||
<div class="rc-input"> | ||
<label class="rc-input__label"> | ||
<div class="rc-input__wrapper"> | ||
<div class="rc-input__icon"> | ||
{{> icon block="rc-input__icon-svg" icon="magnifier" }} | ||
</div> | ||
<input name="name" type="text" class="rc-input__element js-tagpicker-search" placeholder="{{_ "Search"}}" autofocus autocomplete="off"> | ||
</div> | ||
</label> | ||
</div> | ||
</div> | ||
<div class="tags"> | ||
<ul class="tag-list"> | ||
{{#each tags}} | ||
<li class="tag-{{_id}} tag-picker-item" data-tag="{{_id}}" title="{{name}}"> | ||
<span>{{name}}</span> | ||
</li> | ||
{{else}} | ||
<li class="tag-new tag-picker-item" data-tag="new"> | ||
<span>{{_ "Tag_Add"}} {{filter}}</span> | ||
</li> | ||
{{/each}} | ||
</ul> | ||
</div> | ||
</div> | ||
</template> |
Oops, something went wrong.