Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template>
  2.   <div>
  3.     <v-header :invisibleBeforeStick="false" :stickAfter="0"></v-header>
  4.     <div class="container">
  5.       <div class="row">
  6.         <div class="col-12  py-10">
  7.           <h1 class="calculate-item__title black bold">
  8.             We deliver every 2 weeks.
  9.           </h1>
  10.           <p class="calculate-item__desc text-primary text-primary--bigger gray mt-3">
  11.             Experienced teams led by professional PMs.
  12.           </p>
  13.         </div>
  14.       </div>
  15.       <div class="row">
  16.         <div class="col-lg-12 mb-5 hidden-md-up">
  17.  
  18.           <button class="show-filters-button"
  19.                   @click.stop="toggleBlockVisibility('team-filters', 'hidden-sm-down', $event)">
  20.             <span class="no-events">show filters</span>
  21.           </button>
  22.  
  23.         </div>
  24.       </div>
  25.       <div class="row justify-content-between mb-10 hidden-sm-down" id="team-filters">
  26.         <div class="col-12 col-md-auto">
  27.  
  28.           <dropdown :options="platformsName"
  29.                     :chosen="currentProjectType"
  30.                     @value="platformFilterChanged($event)"></dropdown>
  31.  
  32.         </div>
  33.         <div class="col-12 col-md-auto mt-3 mt-md-0" style="margin-right: auto">
  34.  
  35.           <dropdown :options="industryNames"
  36.                     :chosen="currentProjectIndustry"
  37.                     @value="industryFilterChanged($event)"></dropdown>
  38.  
  39.         </div>
  40.         <div class="col-12 col-md-auto mt-3 mt-md-0">
  41.  
  42.           <!--<dropdown :options="projectFilters"-->
  43.           <!--:chosen="'Experience'"-->
  44.           <!--@value="experienceFilterChanged($event)"></dropdown>-->
  45.  
  46.         </div>
  47.       </div>
  48.     </div>
  49.     <div class="container pb-5">
  50.       <div class="row">
  51.         <div class="col-12">
  52.           <div class="align-items-center justify-content-center team-card-stub">
  53.             <h3 class="text-center black uppercase">Nothing to show. Sorry.</h3>
  54.           </div>
  55.  
  56.           <div v-if="!teamsFetched"
  57.                style="width: 100%; height: 300px;"
  58.                class="d-flex justify-content-center align-items-center">
  59.             <spinner :size="'50px'"></spinner>
  60.           </div>
  61.  
  62.           <transition-group appear name="fade">
  63.             <router-link v-for="(team, index) in teams"
  64.                          v-if="doesTeamContainProjectPlatform(team) && doesTeamContainIndustry(team)"
  65.                          :to="{ name: 'Team', params: { name: team.slug }}"
  66.                          :key="team.id"
  67.                          :class="['d-block no-underline mb-5']">
  68.               <team-card :team="team"
  69.                          @click.native="chooseTeam(team.id)"></team-card>
  70.             </router-link>
  71.           </transition-group>
  72.  
  73.  
  74.         </div>
  75.       </div>
  76.     </div>
  77.  
  78.     <footer-section></footer-section>
  79.   </div>
  80. </template>
  81.  
  82. <script>
  83.   import { mapActions, mapState, mapGetters } from 'vuex';
  84.   import _ from 'lodash';
  85.   import qs from 'querystring';
  86.   import vHeader from '../common/header/index';
  87.   import footerSection from '../blocks/footer';
  88.   import teamCard from '../blocks/teamCard/teamCardDefault';
  89.   import dropdown from '../bases/dropdown';
  90.   import spinner from '../bases/spinner';
  91.   import {
  92.     trackTeamsListPlatformFilter,
  93.     trackTeamsListIndustryFilter,
  94.     trackTeamsListExperienceFilter,
  95.   } from '../../services/analytics';
  96.  
  97.   const SORT = {
  98.     EXPERIENCE: 'Experience',
  99.     SIZE: 'Bigger teams',
  100.     PROJECTS: 'Projects completed',
  101.   };
  102.  
  103.   const SELECTBOX_ALL_VALUE = 'All';
  104.  
  105.   function withAll(items) {
  106.     return [SELECTBOX_ALL_VALUE].concat(items);
  107.   }
  108.  
  109.   export default {
  110.     name: 'Teams',
  111.     data() {
  112.       return {
  113.         teamsFetched: false,
  114.         filterTeamsByPlatform: '',
  115.         filterTeamsByIndustry: '',
  116.         filterQuery: '',
  117.         sortTeamsBy: '',
  118.         projectFilters: [
  119.           SORT.EXPERIENCE,
  120.           SORT.SIZE,
  121.           SORT.PROJECTS,
  122.         ],
  123.       };
  124.     },
  125.     components: {
  126.       vHeader,
  127.       teamCard,
  128.       dropdown,
  129.       spinner,
  130.       footerSection,
  131.     },
  132.     watch: {
  133.       filterTeamsByPlatform() {
  134.         this.filterQuery = this.projectsFilterQuery();
  135.       },
  136.       filterTeamsByIndustry() {
  137.         this.filterQuery = this.projectsFilterQuery();
  138.       },
  139.     },
  140.     methods: {
  141.       ...mapActions([
  142.         'chooseTeam',
  143.         'setTeams',
  144.         'appendTeams',
  145.         'setPlatforms',
  146.         'setProjectIndustry',
  147.         'setIndustries',
  148.       ]),
  149.       toggleBlockVisibility(id, className, event) {
  150.         const el = document.getElementById(id);
  151.  
  152.         // Dirty solution TODO fix later
  153.         if (event.target.classList.contains('show-filters-button')) {
  154.           event.target.classList.toggle('show-filters-button--active');
  155.         }
  156.  
  157.         return el.classList.toggle(className);
  158.       },
  159.       sortTeams(filter) {
  160.         switch (filter) {
  161.           case SORT.EXPERIENCE:
  162.             return this.sortTeamsByYearsActive;
  163.           case SORT.SIZE:
  164.             return this.sortTeamsByBiggerTeam;
  165.           case SORT.PROJECTS:
  166.             return this.sortTeamsByProjectsCompleted;
  167.           default:
  168.             return this.sortTeamsByYearsActive;
  169.         }
  170.       },
  171.       doesTeamContainProjectPlatform(team) {
  172.         if (this.filterTeamsByPlatform === SELECTBOX_ALL_VALUE) {
  173.           return true;
  174.         }
  175.  
  176.         return team.projects && team.projects
  177.           .some(project => project.platforms
  178.             .some(platform => platform.platform.name === this.filterTeamsByPlatform));
  179.       },
  180.       doesTeamContainIndustry(team) {
  181.         const industryName = this.filterTeamsByIndustry || this.currentProjectIndustry;
  182.  
  183.         if (industryName === SELECTBOX_ALL_VALUE) {
  184.           return true;
  185.         }
  186.  
  187.         return team.projects && team.projects
  188.           .some((project) => {
  189.             if (project.industry === null) {
  190.               return false;
  191.             }
  192.  
  193.             return project.industry.name === industryName;
  194.           });
  195.       },
  196.       platformFilterChanged($event) {
  197.         if (this.filterTeamsByPlatform) {
  198.           trackTeamsListPlatformFilter($event);
  199.         }
  200.  
  201.         this.filterTeamsByPlatform = $event;
  202.       },
  203.       industryFilterChanged($event) {
  204.         if (this.filterTeamsByIndustry) {
  205.           trackTeamsListIndustryFilter($event);
  206.         }
  207.  
  208.         this.filterTeamsByIndustry = $event;
  209.       },
  210.       experienceFilterChanged($event) {
  211.         if (this.sortTeamsBy) {
  212.           trackTeamsListExperienceFilter($event);
  213.         }
  214.  
  215.         this.sortTeamsBy = $event;
  216.       },
  217.       projectsFilterQuery() {
  218.         const params = {
  219.           projects__industry_id: _.find(this.industries, { slug: this.filterTeamsByIndustry }),
  220.           projects__platforms__platform_id: _.find(this.platforms, {
  221.             name: this.filterTeamsByPlatform,
  222.           }),
  223.         };
  224.  
  225.         const query = Object.keys(params)
  226.           .filter(key => params[key])
  227.           .reduce((acc, key) => Object.assign({
  228.             [key]: params[key],
  229.           }, acc), {});
  230.  
  231.         return `/api/v1/teams?${qs.stringify(query)}`;
  232.       },
  233.     },
  234.     computed: {
  235.       ...mapGetters([
  236.         'sortTeamsByYearsActive',
  237.         'sortTeamsByProjectsCompleted',
  238.         'sortTeamsByBiggerTeam',
  239.         'sortTeamsByYearsActive',
  240.       ]),
  241.       ...mapState({
  242.         teams: state => state.base.teams,
  243.         industries: state => state.base.industries,
  244.         platforms: state => state.base.platforms,
  245.         industryNames: state => withAll(Object.values(state.base.industries).map(el => el.name)),
  246.         currentProjectType: state => SELECTBOX_ALL_VALUE || state.project.type,
  247.         currentProjectIndustry: (state) => {
  248.           const industry = _.find(state.base.industries, {
  249.             id: state.project.industry,
  250.           });
  251.  
  252.           return (industry && industry.name) || SELECTBOX_ALL_VALUE;
  253.         },
  254.         currentProjectTeamName: state => state.project.team || '',
  255.         platformsName: state => withAll(state.base.platforms.map(el => el.name)),
  256.       }),
  257.     },
  258.     created() {
  259.       this.$http.get('teams?limit=100500&with=projects,awards,members,clients&enabled=1')
  260.         .then((response) => {
  261.           this.setTeams(response.body.payload);
  262.           this.teamsFetched = true;
  263.         }, () => {});
  264.  
  265.       this.$http.get('industries')
  266.         .then((response) => {
  267.           this.setIndustries(response.body.payload);
  268.         }, () => {});
  269.  
  270.       this.$http.get('platforms').then((response) => {
  271.         this.setPlatforms(response.body.payload);
  272.       }, () => {});
  273.     },
  274.   };
  275. </script>
  276.  
  277. <style lang="scss">
  278.   @import "../../assets/styles/elements/teams-page.scss";
  279.   @import "../../assets/styles/elements/show-filters-button";
  280. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement