1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-21 15:54:22 +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'; 'use strict';
Application.Controllers.controller('HomeController', ['$scope', '$stateParams', 'lastMembersPromise', 'upcomingEventsPromise', 'twitterNamePromise', Application.Controllers.controller('HomeController', ['$scope', '$stateParams', 'upcomingEventsPromise',
function ($scope, $stateParams, lastMembersPromise, upcomingEventsPromise, twitterNamePromise) { function ($scope, $stateParams, upcomingEventsPromise) {
/* PUBLIC SCOPE */ /* PUBLIC SCOPE */
// The last registered members who confirmed their addresses
$scope.lastMembers = lastMembersPromise;
// The closest upcoming events // The closest upcoming events
$scope.upcomingEvents = upcomingEventsPromise; $scope.upcomingEvents = upcomingEventsPromise;
// Twitter username
$scope.twitterName = twitterNamePromise.setting.value;
/** /**
* Test if the provided event run on a single day or not * Test if the provided event run on a single day or not
* @param event {Object} single event from the $scope.upcomingEvents array * @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 // The admin blogpost
$scope.homeBlogpost = null; $scope.homeBlogpost = null;
/* PRIVATE SCOPE */ // constructor
/**
* Kind of constructor: these actions will be realized first when the directive is loaded
*/
const initialize = function () { const initialize = function () {
Setting.get({ name: 'home_blogpost' }, function (data) { Setting.get({ name: 'home_blogpost' }, function (data) {
$scope.homeBlogpost = data.setting.value; $scope.homeBlogpost = data.setting.value;

View File

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

View File

@ -1,32 +1,43 @@
/* global twitterFetcher */ /* global twitterFetcher */
/** /**
* This directive will allow show latest tweet. * This directive will show the last tweet.
* Usage: <twitter profile="{{twitterName}}"/> * Usage: <twitter />
*/ */
Application.Directives.directive('twitter', [ function () { Application.Directives.directive('twitter', ['Setting',
return ({ function (Setting) {
restrict: 'E', return ({
scope: { restrict: 'E',
profile: '@' templateUrl: '<%= asset_path "home/twitter.html" %>',
}, link ($scope, element, attributes) {
templateUrl: '<%= asset_path "home/twitter.html" %>', // Twitter username
link ($scope, element, attributes) { $scope.twitterName = null;
const configProfile = {
'profile': { 'screenName': $scope.profile }, // constructor
'domId': 'twitter', const initialize = function () {
'maxTweets': 1, Setting.get({ name: 'twitter_name' }, function (data) {
'enableLinks': true, $scope.twitterName = data.setting.value;
'showUser': false, if ($scope.twitterName) {
'showTime': true, const configProfile = {
'showImages': false, 'profile': { 'screenName': $scope.twitterName },
'showRetweet': true, 'domId': 'twitter',
'showInteraction': false, 'maxTweets': 1,
'lang': Fablab.locale 'enableLinks': true,
}; 'showUser': false,
if ($scope.profile) { 'showTime': true,
twitterFetcher.fetch(configProfile); '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: { resolve: {
lastMembersPromise: ['Member', function (Member) { return Member.lastSubscribed({ limit: 4 }).$promise; }], upcomingEventsPromise: ['Event', function (Event) { return Event.upcoming({ limit: 3 }).$promise; }]
upcomingEventsPromise: ['Event', function (Event) { return Event.upcoming({ limit: 3 }).$promise; }],
twitterNamePromise: ['Setting', function (Setting) { return Setting.get({ name: 'twitter_name' }).$promise; }]
} }
}) })
.state('app.public.privacy', { .state('app.public.privacy', {

View File

@ -8,42 +8,9 @@
<div class="col-lg-4 m-t-lg"> <div class="col-lg-4 m-t-lg">
<twitter profile="{{twitterName}}" ng-show="twitterName"/> <twitter></twitter>
<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>
<members></members>
</div> </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="panel-heading b-b small">
<div class="pull-right text-xs align"> <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"> <span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x text-yellow"></i> <i class="fa fa-circle fa-stack-2x text-yellow"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse text-white"></i> <i class="fa fa-twitter fa-stack-1x fa-inverse text-white"></i>