Skip to content

Instantly share code, notes, and snippets.

View zifnab87's full-sized avatar

Michail Michailidis zifnab87

View GitHub Profile
@zifnab87
zifnab87 / ActorListPaginationTracking.vue
Created February 14, 2021 14:42
how to track paginatation changes with b-pagination-nav
<template>
<!-- [....] -->
<b-pagination-nav
v-model="FPS.currentPage"
align="right"
use-router
:number-of-pages="Math.max(1,totalPages)"
:link-gen="pageChanged"
/>
<!-- [....] -->
@zifnab87
zifnab87 / ActorsListWatcher.vue
Last active February 14, 2021 14:47
watcher of $route query on a component containing b-table
<script>
export default {
// [...]
watch: {
'$route.query': {
handler(newVal) {
const currentPageFromUrl = parseInt(newVal.currentPage)
this.FPS = this.sanitizeQueryParams(newVal)
this.$nextTick(() => {
if (currentPageFromUrl) {
@zifnab87
zifnab87 / ActorsListBTable.vue
Created February 14, 2021 14:34
b-table vue for server side rendering
<b-table
:items="dataProvider"
:fields="fields"
:per-page="FPS.perPage"
:filter="FPS.filter"
:sort-by="FPS.sortBy"
:sort-desc="FPS.sortDesc"
:head-variant="headVariant"
:current-page="FPS.currentPage"
:busy="isBusy"
@zifnab87
zifnab87 / ActorController.java
Created February 14, 2021 14:33
Java spring boot controller with api helper for filtering sorting and pagination
@RestController
@RequestMapping("actors")
public class ActorController {
@Autowired
private ActorRepository repository;
@Autowired
private FilterService<Actor, Long> filterService;
@zifnab87
zifnab87 / ActorsList.vue
Last active February 14, 2021 15:03
component using b-table and table-utils-mixins gist
<template>
<b-container fluid>
<b-table
id="actors"
:items="dataProvider"
:fields="fields"
:per-page="FPS.perPage"
:filter="FPS.filter"
:sort-by="FPS.sortBy"
:sort-desc="FPS.sortDesc"
@zifnab87
zifnab87 / table-utilis-mixin.js
Last active February 14, 2021 15:04
b-table mixin for server integration rest api
import request from '@/utils/request'
export default {
data() {
return {
totalRows: 0,
totalPages: 1,
isBusy: false,
FPS: {
filter: {},
currentPage: 1
@zifnab87
zifnab87 / b-form-select-ie11.vue
Last active March 27, 2020 09:11
vuejs 2.0 b-form-select that works with IE11 - we want to make a request on change - a method with @change.native is needed because nothing is fired with v-model or `@input`
<template>
<div>
<b-form-select
:options="assignees"
value-field="id"
text-field="name"
v-model="selectedAssignee.id"
@change.native="changeAssignee($event, orderId)"
>
</b-form-select>
@zifnab87
zifnab87 / CaretPositionedVueSimpleSuggest.vue
Last active January 7, 2020 23:24
absolutely positioned vue-simple-suggest at caret position after pressing @ in a textarea element (with help of textarea-caret)
<template>
<b-container class="editor" fluid>
<b-row :style="{width:'70%', margin: '0 auto'}">
<b-col>
<textarea id="absolute-at-editor" :style="{width:'100%', height: '500px', position: 'relative'}"
v-model="text"
@input="calculateQuery()"
@keydown="$refs.suggest.onKeyDown($event); $refs.suggest.onListKeyUp($event)"></textarea>
<vue-simple-suggest :style="{left: caret.left +'px', top: caret.top + caret.height + 'px'}"
ref="suggest"
@zifnab87
zifnab87 / dixit.java
Last active November 28, 2022 02:11
Dixit Board game - quick and dirty one round score calculation
import java.util.LinkedHashMap;
import java.util.Map;
//as described here: https://boardgamegeek.com/boardgame/39856/dixit
public class Dixit {
public static void main(String[] args) {
//execution: score of one round for dixit
LinkedHashMap<String,String> playerVotes = new LinkedHashMap<>();
playerVotes.put("Player1", null); // story teller doesn't vote a players card