<main id="main" class="news--page">
    <div class="container">
        <div class="row breadcrumbs">
            <div class="col-md-10 offset-md-1 col-lg-8 offset-lg-2">
                <div class="breadcrumbs-container row">
                    <div class="col-12 col-lg-8 breadcrumb-col">
                        <nav aria-label="Breadcrumbs" class="mr-auto">
                            <ol class="breadcrumb ">
                                <li class="breadcrumb-item"><a href="/">Hem</a></li>
                                <li class="breadcrumb-item"><a href="/utbildning">Utbildning</a></li>
                                <li class="breadcrumb-item"><a href="/utbildning">Utbildning</a></li>
                                <li class="breadcrumb-item active" aria-current="page">En sjukt lång text som egentligen inte borde vara här. Men så blir det när man behöver testa vissa saker. :)</li>
                            </ol>
                        </nav>
                    </div>
                    <div class="col-12 col-lg-4 breadcrumb-col enablevue">
                        <nav class="breadcrumbs-actions float-md-left float-lg-right" aria-label="Page functions" id="breadcrumbs">
                            <ul class="page-functions-list list-unstyled">
                                <li v-if="isSetAsFavourite" id='remove-bookmark-container' class="page-functions-list-item">
                                    <a href="javascript:void(0)" id="bookmarkremove" class="small-font" v-on:click="removeFavourite()">
                                    <i class="material-icons blue">favorite</i>
                                    <span>Ta bort favorit</span>
                                </a>
                                </li>
                                <li v-else id="save-bookmark-container" class="page-functions-list-item">
                                    <a href="javascript:void(0)" id="bookmarksave" class="small-font" v-on:click="addFavourite()">
                                    <i class="material-icons">favorite_border</i>
                                    <span>Spara</span>
                                </a>
                                </li>
                                <li class="page-functions-list-item">
                                    <div id="readspeaker_button1" class="rs_skip rsbtn rs_preserve">
                                        <a rel="nofollow" class="rsbtn_play" accesskey="L" title="webReader" href="//app-eu.readspeaker.com/cgi-bin/rsent?customerid=5305&amp;lang=sv_se&amp;readid=maincontent;url=">
                                        <span class="rsbtn_left rsimg rspart"><span
                                                class="rsbtn_text"><span>Lyssna</span></span></span>
                                        <span class="rsbtn_right rsimg rsplay rspart"></span>
                                    </a>
                                    </div>
                                </li>
                            </ul>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="container">
        <div class="row title-container">
            <div class="col-md-10 mt-xs offset-md-1 col-lg-8 offset-lg-2">
                <h1 class="heading-level-1">Nyheter</h1>
            </div>
        </div>
    </div>
    <div class="enablevue">
        <newspagecomponent url="http://localhost:2000/production/KitModules/News/Services/NewsDataService.asmx/GetNews" request="{&quot;request&quot;:{&quot;Settings&quot;:{&quot;ImageWidth&quot;:300,&quot;ImageHeight&quot;:300,&quot;PreviewLength&quot;:200,&quot;PageIndex&quot;:0,&quot;MonthFilterCount&quot;:6,&quot;IsInit&quot;:true,&quot;NewsPageId&quot;:11967,&quot;PageSize&quot;:50,&quot;LanguageId&quot;:&quot;sv-SE&quot;}}}"
            show-more-text="Show more"></newspagecomponent>
    </div>
</main>
{{!< ../_preview-page}}
<main id="main" class="news--page">
    {{render '@breadcrumbs' }}

    {{#if title.value}}
    <div class="container">
        <div class="row title-container">
            <div class="col-md-10 mt-xs offset-md-1 col-lg-8 offset-lg-2">
                <h1 class="heading-level-1" {{{title.epiEditAttribute}}}>{{title.value}}</h1>
            </div>
        </div>
    </div>
    {{/if}}
    <div class="enablevue">
        <newspagecomponent url="{{url}}" request="{{request}}"
            show-more-text="{{componentTexts.showMoreText.value}}"
        ></newspagecomponent>
    </div>
</main>
{
  "title": {
    "value": "Nyheter",
    "epiEditAttribute": ""
  },
  "componentTexts": {
    "showMoreText": {
      "value": "Show more"
    }
  },
  "url": "http://localhost:2000/production/KitModules/News/Services/NewsDataService.asmx/GetNews",
  "request": "{\"request\":{\"Settings\":{\"ImageWidth\":300,\"ImageHeight\":300,\"PreviewLength\":200,\"PageIndex\":0,\"MonthFilterCount\":6,\"IsInit\":true,\"NewsPageId\":11967,\"PageSize\":50,\"LanguageId\":\"sv-SE\"}}}"
}
  • Content:
    Vue.component("newspagecomponent", {
      props: ["url", "request", "showMoreText"],
      data() {
        return {
          cPageIndex: 0,
          nPageIndex: 0,
          fetchUrl: "",
          news: [],
          promotedNewsItem: "",
          loading: false,
          loadingMore: false,
          pageIndex: 0,
        };
      },
      mounted() {
        if (this.url && this.request) {
          this.fetchUrl = this.url;
          this.init(this.url, JSON.parse(this.request));
          console.log({ "showMoreText": this.showMoreText })
        }
      },
      methods: {
        userWantsToFetchMore() {
          this.pageIndex++;
          let curReq = JSON.parse(this.request);
    
          console.log({ curReq: curReq })
          let request = {
            request: {
              Settings: {
                PageIndex: this.pageIndex,
                ImageHeight: curReq.request.Settings.ImageHeight,
                ImageWidth: curReq.request.Settings.ImageWidth,
                DefaultCity: curReq.request.Settings.DefaultCity,
                LanguageId: this.lang,
                MonthFilterCount: curReq.request.Settings.MonthFilterCount,
                NewsPageId: curReq.request.Settings.NewsPageId,
                PageSize: curReq.request.Settings.PageSize,
                PreviewLength: curReq.request.Settings.PreviewLength,
                IsPersonalized: curReq.request.Settings.IsPersonalized,
                Location: curReq.request.Settings.Location,
                Groups: curReq.request.Settings.Groups
              }
            }
          };
          this.fetchMore(this.fetchUrl, request);
        },
        async fetchMore(url, req) {
          try {
            this.loadingMore = true;
            const response = await fetch(url, {
              method: "post",
              headers: {
                Accept: "application/json, text/plain, */*",
                "Content-Type": "application/json;charset=UTF-8"
              },
              body: JSON.stringify(req)
            });
            const data = await response.json();
            if (data.d) {
              if (data.d.Events && data.d.Events.length > 0) {
                await data.d.Events.map(event => {
                  event.PublishedDate = moment(event.PublishedDate)
                    .locale(data.d.Settings.LanguageId)
                    .format("dddd D MMMM YYYY");
                });
    
                this.news.push(...data.d.Events);
              }
              this.cPageIndex = data.d.CurrentPageIndex;
              this.nPageIndex = data.d.NextPageIndex;
            }
            this.loadingMore = false;
            console.log(data);
          } catch (error) {
            console.log(error);
            this.loadingMore = false;
          }
        },
        async init(url, req) {
          try {
            this.loading = true;
            const response = await fetch(url, {
              method: "post",
              headers: {
                Accept: "application/json, text/plain, */*",
                "Content-Type": "application/json;charset=UTF-8"
              },
              body: JSON.stringify(req)
            });
            const data = await response.json();
            if (data.d) {
              if (data.d.PromotedNewsItem) {
                data.d.PromotedNewsItem.PublishedDate = moment(
                  data.d.PromotedNewsItem.PublishedDate
                )
                  .locale(data.d.Settings.LanguageId)
                  .format("dddd D MMMM YYYY");
                this.promotedNewsItem = data.d.PromotedNewsItem;
              }
              if (data.d.Events && data.d.Events.length > 0) {
                await data.d.Events.map(event => {
                  event.PublishedDate = moment(event.PublishedDate)
                    .locale(data.d.Settings.LanguageId)
                    .format("dddd D MMMM YYYY");
                });
    
                this.news.push(...data.d.Events);
              }
              this.lang = data.d.Settings.LanguageId;
              this.cPageIndex = data.d.CurrentPageIndex;
              this.nPageIndex = data.d.NextPageIndex;
            }
            this.loading = false;
            console.log(data);
          } catch (error) {
            console.log(error);
            this.loading = false;
          }
        }
      },
      template: `
    <div class="container mb-5 newspagecomponent vld-parent">
          <vloading :height="32" :width="32" :color="'#404040'" :is-full-page="false" :active.sync="loading"></vloading>
          <newslist :showMore="showMoreText" key="1" :promotedNewsItem="promotedNewsItem" @fetchMore="userWantsToFetchMore" :loadingMore="loadingMore" v-if="news" :loading="loading" :news="news" :cPageIndex="cPageIndex" :nPageIndex="nPageIndex"></newslist>
    </div>
      `
    });
    
    Vue.component("newslist", {
      props: [
        "news",
        "cPageIndex",
        "nPageIndex",
        "loading",
        "loadingMore",
        "promotedNewsItem",
        "showMore"
      ],
      data() {
        return {
          show: this.showMore
        };
      },
      methods: {
        fetchMore() {
          this.$emit("fetchMore");
        }
      },
      template: `
    <div class="row newslist">
      <div class="col-12">
        <ul class="list-unstyled">
          <news-item v-if="this.promotedNewsItem" 
          :id="this.promotedNewsItem.UniqueId" 
          :img="this.promotedNewsItem.ImageData"
          :imgAlt="this.promotedNewsItem.ImageText"
          :url="this.promotedNewsItem.Url"
          :title="this.promotedNewsItem.Title"
          :excerpt="this.promotedNewsItem.Intro"
          :date="this.promotedNewsItem.PublishedDate"
           /> 
          <news-item :id="news.UniqueId" :img="news.ImageData" :imgAlt="news.ImageText" :url="news.Url" :title="news.Title" :excerpt="news.Intro" :date="news.PublishedDate" v-for="news in this.news" :key="news.EventPageId"></news-item>
        </ul>
      </div>
        <div class="col-12" v-if="this.cPageIndex < this.nPageIndex || !this.cPageIndex == this.nPageIndex && !this.loading">
          <transition name="fade" mode="out-in">
            <button key="1" @click="this.fetchMore" class="d-flex align-items-center button-small ml-auto mr-auto" v-if="!this.loadingMore">
              {{show}}
            </button>
            <button key="2" disabled class="d-flex align-items-center button-small ml-auto mr-auto" v-else>
              <i class="material-icons">cached</i>
            </button>
          </transition>
        </div>
    </div>
      `
    });
    
    Vue.component("news-item", {
      props: ["id", "img", "imgAlt", "url", "title", "excerpt", "date"],
      template: `
    <li class="row news-container">
      <article :id="this.id"   class="news-item col-md-10 offset-md-1 col-lg-8 offset-lg-2"  >
      <div class="row">
        <div class="col-12 col-md-3" v-if="this.img">
          <a :href="this.url" class="d-flex flex-row align-items-start" >
            <img :src="this.img" :alt="this.imgAlt" />
          </a>
        </div>
        <div class="col-12 col-md-9">
          <div class="d-flex flex-column" >
            <a :href="this.url" v-if="this.url && this.title">
              <h2 class="heading-level-3">
                {{this.title}}
              </h2>
            </a>
            <p class="mb-0" v-if="this.excerpt">{{this.excerpt}}</p>
            <p class="mb-0 mt-2" v-if="this.date">{{this.date | capitalize}}</p>
          </div>
        </div>
      </div>
      </article>
    </li>
      `
    });
  • URL: /components/raw/newspage/NewsPage.js
  • Filesystem Path: src\components\03-pages\NewsPage\NewsPage.js
  • Size: 7 KB
  • Content:
    .newspagecomponent {
    
      .vld-overlay{
        min-height: 50px;
      }
    
      .newslist {
        .news-container{
          border-top: 1px solid $grey-border;
          .news-item {
            
            padding-top: $sm-space;
            padding-bottom: $sm-space;
      
            img {
              margin-right: $xs-space;
              @include media-breakpoint-down(sm) {
                margin-bottom: $xs-space;
              }
            }
          }
        }
      }
    }
    
    // .article {
    //   width: 100%;
    
    //   .article--constrained {
    //     margin: 0 auto;
    //     width: 100%;
    //     @include media-breakpoint-only(sm) {
    //       max-width: 600px;
    //     }
    //     @include media-breakpoint-only(md) {
    //       max-width: 600px;
    //     }
    //     @include media-breakpoint-only(lg) {
    //       max-width: 640px;
    //     }
    //     @include media-breakpoint-only(xl) {
    //       max-width: 760px;
    //     }
    //   }
    // }
    
    // .article--bordered {
    //   border-top: 1px solid $grey-border;
    //   &:last-child {
    //     border-bottom: none;
    //   }
    // }
    .button-small {
      cursor: pointer;
      p {
        margin-bottom: 0px;
      }
      .material-icons {
        margin-bottom: 0px;
        animation-name: spin;
        animation-duration: 1000ms;
        animation-iteration-count: infinite;
        animation-timing-function: linear;
      }
    }
    [v-cloak] {
      display: none;
    }
    @keyframes spin {
      from {
        transform: rotate(0deg);
      }
      to {
        transform: rotate(360deg);
      }
    }
    // .news--page {
    //   [v-cloak] {
    //     display: none;
    //   }
    //   .loading--indicator {
    //     .material-icons {
    //       margin-bottom: 0px;
    //       animation-name: spin;
    //       animation-duration: 1000ms;
    //       animation-iteration-count: infinite;
    //       animation-timing-function: linear;
    //     }
    //   }
    // }
    
  • URL: /components/raw/newspage/NewsPage.scss
  • Filesystem Path: src\components\03-pages\NewsPage\NewsPage.scss
  • Size: 1.8 KB

There are no notes for this item.