1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

[ongoing] move homepage components to standalone directives

- twitter
- members
This commit is contained in:
Sylvain 2020-01-22 12:43:08 +01:00
parent fd1778b465
commit 89e146d419
9 changed files with 96 additions and 95 deletions

View File

@ -1,28 +1,12 @@
/* eslint-disable
no-undef,
*/
// TODO: This file was created by bulk-decaffeinate.
// Fix any style issues and re-enable lint.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
'use strict';
Application.Controllers.controller('HomeController', ['$scope', '$stateParams', 'lastMembersPromise', 'upcomingEventsPromise', 'twitterNamePromise',
function ($scope, $stateParams, lastMembersPromise, upcomingEventsPromise, twitterNamePromise) {
Application.Controllers.controller('HomeController', ['$scope', '$stateParams', 'upcomingEventsPromise',
function ($scope, $stateParams, upcomingEventsPromise) {
/* PUBLIC SCOPE */
// The last registered members who confirmed their addresses
$scope.lastMembers = lastMembersPromise;
// The closest upcoming events
$scope.upcomingEvents = upcomingEventsPromise;
// Twitter username
$scope.twitterName = twitterNamePromise.setting.value;
/**
* Test if the provided event run on a single day or not
* @param event {Object} single event from the $scope.upcomingEvents array

View File

@ -0,0 +1,22 @@
Application.Directives.directive('members', [ 'Member',
function (Member) {
return ({
restrict: 'E',
templateUrl: '<%= asset_path "home/members.html" %>',
link ($scope, element, attributes) {
// The last registered members who confirmed their addresses
$scope.lastMembers = null;
// constructor
const initialize = function () {
Member.lastSubscribed({ limit: 4 }, function (data) {
$scope.lastMembers = data;
})
};
// !!! MUST BE CALLED AT THE END of the directive
return initialize();
}
});
}
]);

View File

@ -7,11 +7,7 @@ Application.Directives.directive('news', [ 'Setting',
// The admin blogpost
$scope.homeBlogpost = null;
/* PRIVATE SCOPE */
/**
* Kind of constructor: these actions will be realized first when the directive is loaded
*/
// constructor
const initialize = function () {
Setting.get({ name: 'home_blogpost' }, function (data) {
$scope.homeBlogpost = data.setting.value;

View File

@ -7,11 +7,7 @@ Application.Directives.directive('projects', [ 'Project',
// The last projects published/documented on the plateform
$scope.lastProjects = null;
/* PRIVATE SCOPE */
/**
* Kind of constructor: these actions will be realized first when the directive is loaded
*/
// constructor
const initialize = function () {
Project.lastPublished(function (data) {
$scope.lastProjects = data;

View File

@ -1,32 +1,43 @@
/* global twitterFetcher */
/**
* This directive will allow show latest tweet.
* Usage: <twitter profile="{{twitterName}}"/>
* This directive will show the last tweet.
* Usage: <twitter />
*/
Application.Directives.directive('twitter', [ function () {
return ({
restrict: 'E',
scope: {
profile: '@'
},
templateUrl: '<%= asset_path "home/twitter.html" %>',
link ($scope, element, attributes) {
const configProfile = {
'profile': { 'screenName': $scope.profile },
'domId': 'twitter',
'maxTweets': 1,
'enableLinks': true,
'showUser': false,
'showTime': true,
'showImages': false,
'showRetweet': true,
'showInteraction': false,
'lang': Fablab.locale
};
if ($scope.profile) {
twitterFetcher.fetch(configProfile);
Application.Directives.directive('twitter', ['Setting',
function (Setting) {
return ({
restrict: 'E',
templateUrl: '<%= asset_path "home/twitter.html" %>',
link ($scope, element, attributes) {
// Twitter username
$scope.twitterName = null;
// constructor
const initialize = function () {
Setting.get({ name: 'twitter_name' }, function (data) {
$scope.twitterName = data.setting.value;
if ($scope.twitterName) {
const configProfile = {
'profile': { 'screenName': $scope.twitterName },
'domId': 'twitter',
'maxTweets': 1,
'enableLinks': true,
'showUser': false,
'showTime': true,
'showImages': false,
'showRetweet': true,
'showInteraction': false,
'lang': Fablab.locale
};
twitterFetcher.fetch(configProfile);
}
})
};
// !!! MUST BE CALLED AT THE END of the directive
return initialize();
}
}
});
}]);
});
}
]);

View File

@ -98,9 +98,7 @@ angular.module('application.router', ['ui.router'])
}
},
resolve: {
lastMembersPromise: ['Member', function (Member) { return Member.lastSubscribed({ limit: 4 }).$promise; }],
upcomingEventsPromise: ['Event', function (Event) { return Event.upcoming({ limit: 3 }).$promise; }],
twitterNamePromise: ['Setting', function (Setting) { return Setting.get({ name: 'twitter_name' }).$promise; }]
upcomingEventsPromise: ['Event', function (Event) { return Event.upcoming({ limit: 3 }).$promise; }]
}
})
.state('app.public.privacy', {

View File

@ -8,42 +8,9 @@
<div class="col-lg-4 m-t-lg">
<twitter profile="{{twitterName}}" ng-show="twitterName"/>
<section class="widget panel b-a" >
<div class="panel-heading small b-b">
<h2 translate>{{ 'app.public.home.latest_registered_members' }}</h2>
</div>
<div class="row m-n">
<div class="col-md-6 b-b b-r block-link" ng-repeat="member in lastMembers" ui-sref="app.logged.members_show({id:member.slug})">
<div class="padder-v">
<span class="avatar avatar-block text-center">
<fab-user-avatar ng-model="member.profile.user_avatar" avatar-class="thumb-50"></fab-user-avatar>
<!-- <i class="on b-white bottom"></i> -->
<a ><span class="user-name m-l-sm text-black m-t-xs">{{member.name}}</span></a>
</span>
</div>
</div>
<!-- TODO EVEN <div class="col-md-6 b-b"> -->
</div>
<div class="m-t-sm m-b-sm text-center" ng-if="!isAuthenticated()">
<button href="#" ng-click="signup($event)" class="btn btn-warning-full width-70 font-sbold rounded text-sm" translate>{{ 'app.public.home.create_an_account' }}</button>
</div>
<div class="m-t-sm m-b-sm text-center" ng-if="isAuthenticated()">
<button href="#" ui-sref="app.logged.members" class="btn btn-warning-full width-70 font-sbold rounded text-sm" translate>{{ 'app.public.home.discover_members' }}</button>
</div>
</section>
<twitter></twitter>
<members></members>
</div>

View File

@ -0,0 +1,27 @@
<section class="widget panel b-a" >
<div class="panel-heading small b-b">
<h2 translate>{{ 'app.public.home.latest_registered_members' }}</h2>
</div>
<div class="row m-n">
<div class="col-md-6 b-b b-r block-link" ng-repeat="member in lastMembers" ui-sref="app.logged.members_show({id:member.slug})">
<div class="padder-v">
<span class="avatar avatar-block text-center">
<fab-user-avatar ng-model="member.profile.user_avatar" avatar-class="thumb-50"></fab-user-avatar>
<!-- <i class="on b-white bottom"></i> -->
<a ><span class="user-name m-l-sm text-black m-t-xs">{{member.name}}</span></a>
</span>
</div>
</div>
</div>
<div class="m-t-sm m-b-sm text-center" ng-if="!isAuthenticated()">
<button href="#" ng-click="signup($event)" class="btn btn-warning-full width-70 font-sbold rounded text-sm" translate>{{ 'app.public.home.create_an_account' }}</button>
</div>
<div class="m-t-sm m-b-sm text-center" ng-if="isAuthenticated()">
<button href="#" ui-sref="app.logged.members" class="btn btn-warning-full width-70 font-sbold rounded text-sm" translate>{{ 'app.public.home.discover_members' }}</button>
</div>
</section>

View File

@ -1,7 +1,7 @@
<section class="widget panel b-a m-t-sm">
<section class="widget panel b-a m-t-sm" ng-show="twitterName">
<div class="panel-heading b-b small">
<div class="pull-right text-xs align">
<a href="https://twitter.com/{{ profile }}" target="_blank">{{ 'app.public.home.follow_us' | translate }}
<a href="https://twitter.com/{{ twitterName }}" target="_blank">{{ 'app.public.home.follow_us' | translate }}
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x text-yellow"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse text-white"></i>