logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

integer_setting.js (1028B)


  1. import { get, set } from 'lodash'
  2. import ModifiedIndicator from './modified_indicator.vue'
  3. export default {
  4. components: {
  5. ModifiedIndicator
  6. },
  7. props: {
  8. path: String,
  9. disabled: Boolean,
  10. min: Number,
  11. expert: [Number, String]
  12. },
  13. computed: {
  14. pathDefault () {
  15. const [firstSegment, ...rest] = this.path.split('.')
  16. return [firstSegment + 'DefaultValue', ...rest].join('.')
  17. },
  18. state () {
  19. const value = get(this.$parent, this.path)
  20. if (value === undefined) {
  21. return this.defaultState
  22. } else {
  23. return value
  24. }
  25. },
  26. defaultState () {
  27. return get(this.$parent, this.pathDefault)
  28. },
  29. isChanged () {
  30. return this.state !== this.defaultState
  31. },
  32. matchesExpertLevel () {
  33. return (this.expert || 0) <= this.$parent.expertLevel
  34. }
  35. },
  36. methods: {
  37. update (e) {
  38. set(this.$parent, this.path, parseInt(e.target.value))
  39. },
  40. reset () {
  41. set(this.$parent, this.path, this.defaultState)
  42. }
  43. }
  44. }