Initial commit

This commit is contained in:
zhongjin
2020-06-15 10:58:47 +08:00
commit 4f1dfe7564
8590 changed files with 1516878 additions and 0 deletions
@@ -0,0 +1,40 @@
const CoreView = require('backbone/core-view');
const template = require('./group.tpl');
const pluralizeStr = require('dashboard/helpers/pluralize');
const checkAndBuildOpts = require('builder/helpers/required-opts');
const REQUIRED_OPTS = [
'model',
'url'
];
/**
* View for an individual group.
*/
module.exports = CoreView.extend({
tagName: 'li',
className: 'OrganizationList-user',
_PREVIEW_COUNT: 3,
initialize: function (options) {
checkAndBuildOpts(options, REQUIRED_OPTS, this);
},
render: function () {
const sharedMapsCount = this.model.get('shared_maps_count');
const sharedDatasetsCount = this.model.get('shared_tables_count');
this.$el.html(
template({
displayName: this.model.get('display_name'),
sharedMapsCount: pluralizeStr('1 shared map', `${sharedMapsCount} shared maps`, sharedMapsCount),
sharedDatasetsCount: pluralizeStr('1 shared dataset', `${sharedDatasetsCount} shared datasets`, sharedDatasetsCount),
url: this._url,
previewUsers: this.model.users.toArray().slice(0, this._PREVIEW_COUNT),
usersCount: Math.max(this.model.users.length - this._PREVIEW_COUNT, 0)
})
);
return this;
}
});
@@ -0,0 +1,26 @@
<a class="CDB-Text OrganizationList-userLink" href="<%- url %>">
<div class="OrganizationList-userInfo">
<div class="OrganizationList-userInfoName">
<h3 class="CDB-Size-medium OrganizationList-userInfoTitle u-ellipsLongText" title="<%- displayName %>">
<%- displayName %>
</h3>
<h4 class="OrganizationList-userInfoSubtitle u-ellipsLongText">
<%- sharedMapsCount %> &bull; <%- sharedDatasetsCount %>
</h4>
</div>
</div>
<div class="OrganizationList-userInfoData">
<% previewUsers.forEach(function(u) { %>
<span class="UserAvatar is-in-list">
<img class="UserAvatar-img UserAvatar-img--medium" src="<%- u.get('avatar_url') %>" title="<%- u.nameOrUsername() %>" />
</span>
<% }) %>
<% if (usersCount > 0) { %>
<span class="UserAvatar is-in-list">
<span class="UserAvatar-img UserAvatar-img--medium UserAvatar-img--textReplacement">
+<%- usersCount %>
</span>
</span>
<% } %>
</div>
</a>