fustrate-rails 0.4.1.1 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +5 -5
  2. data/config/initializers/jbuilder.rb +13 -0
  3. data/config/initializers/renderers.rb +40 -0
  4. data/config/initializers/sanitize.rb +112 -0
  5. data/config/rubocop/default.yml +96 -0
  6. data/config/rubocop/rails.yml +22 -0
  7. data/lib/fustrate/rails/concerns/clean_attributes.rb +49 -0
  8. data/lib/fustrate/rails/concerns/model.rb +48 -0
  9. data/lib/fustrate/rails/concerns/sanitize_html.rb +34 -0
  10. data/lib/fustrate/rails/engine.rb +14 -7
  11. data/lib/fustrate/rails/services/base.rb +46 -0
  12. data/lib/fustrate/rails/services/generate_csv.rb +35 -0
  13. data/lib/fustrate/rails/services/generate_excel.rb +32 -0
  14. data/lib/fustrate/rails/services/log_edit.rb +132 -0
  15. data/lib/fustrate/rails/spec_helper.rb +62 -0
  16. data/lib/fustrate/rails/version.rb +5 -1
  17. data/lib/fustrate-rails.rb +5 -2
  18. metadata +44 -140
  19. data/vendor/assets/javascripts/awesomplete.js +0 -402
  20. data/vendor/assets/javascripts/fustrate/_module.coffee +0 -140
  21. data/vendor/assets/javascripts/fustrate/components/_module.coffee +0 -3
  22. data/vendor/assets/javascripts/fustrate/components/alert_box.coffee +0 -10
  23. data/vendor/assets/javascripts/fustrate/components/autocomplete.coffee +0 -161
  24. data/vendor/assets/javascripts/fustrate/components/disclosure.coffee +0 -12
  25. data/vendor/assets/javascripts/fustrate/components/drop_zone.coffee +0 -9
  26. data/vendor/assets/javascripts/fustrate/components/dropdown.coffee +0 -48
  27. data/vendor/assets/javascripts/fustrate/components/file_picker.coffee +0 -11
  28. data/vendor/assets/javascripts/fustrate/components/flash.coffee +0 -31
  29. data/vendor/assets/javascripts/fustrate/components/modal.coffee +0 -273
  30. data/vendor/assets/javascripts/fustrate/components/pagination.coffee +0 -84
  31. data/vendor/assets/javascripts/fustrate/components/tabs.coffee +0 -28
  32. data/vendor/assets/javascripts/fustrate/components/tooltip.coffee +0 -72
  33. data/vendor/assets/javascripts/fustrate/generic_form.coffee +0 -30
  34. data/vendor/assets/javascripts/fustrate/generic_page.coffee +0 -40
  35. data/vendor/assets/javascripts/fustrate/generic_table.coffee +0 -57
  36. data/vendor/assets/javascripts/fustrate/listenable.coffee +0 -25
  37. data/vendor/assets/javascripts/fustrate/object.coffee +0 -21
  38. data/vendor/assets/javascripts/fustrate/record.coffee +0 -23
  39. data/vendor/assets/javascripts/fustrate.coffee +0 -6
  40. data/vendor/assets/stylesheets/_fustrate.sass +0 -7
  41. data/vendor/assets/stylesheets/awesomplete.sass +0 -76
  42. data/vendor/assets/stylesheets/fustrate/_colors.sass +0 -12
  43. data/vendor/assets/stylesheets/fustrate/_settings.sass +0 -19
  44. data/vendor/assets/stylesheets/fustrate/components/_components.sass +0 -36
  45. data/vendor/assets/stylesheets/fustrate/components/_functions.sass +0 -41
  46. data/vendor/assets/stylesheets/fustrate/components/alerts.sass +0 -86
  47. data/vendor/assets/stylesheets/fustrate/components/buttons.sass +0 -99
  48. data/vendor/assets/stylesheets/fustrate/components/disclosures.sass +0 -23
  49. data/vendor/assets/stylesheets/fustrate/components/dropdowns.sass +0 -36
  50. data/vendor/assets/stylesheets/fustrate/components/flash.sass +0 -38
  51. data/vendor/assets/stylesheets/fustrate/components/forms.sass +0 -195
  52. data/vendor/assets/stylesheets/fustrate/components/grid.sass +0 -196
  53. data/vendor/assets/stylesheets/fustrate/components/labels.sass +0 -64
  54. data/vendor/assets/stylesheets/fustrate/components/modals.sass +0 -167
  55. data/vendor/assets/stylesheets/fustrate/components/pagination.sass +0 -69
  56. data/vendor/assets/stylesheets/fustrate/components/panels.sass +0 -67
  57. data/vendor/assets/stylesheets/fustrate/components/popovers.sass +0 -19
  58. data/vendor/assets/stylesheets/fustrate/components/tables.sass +0 -62
  59. data/vendor/assets/stylesheets/fustrate/components/tabs.sass +0 -44
  60. data/vendor/assets/stylesheets/fustrate/components/tooltips.sass +0 -28
  61. data/vendor/assets/stylesheets/fustrate/components/typography.sass +0 -391
@@ -1,57 +0,0 @@
1
- class Fustrate.GenericTable extends Fustrate.GenericPage
2
- @blankRow: null
3
- table: null
4
-
5
- initialize: =>
6
- super
7
-
8
- @reloadTable()
9
-
10
- reloadTable: ->
11
-
12
- sortRows: (rows, sortFunction = ->) ->
13
- sorted = ([sortFunction(row), row] for row in rows)
14
- sorted.sort (x, y) ->
15
- if x[0] is y[0] then 0 else if x[0] > y[0] then 1 else -1
16
- sorted.map (row) -> row[1]
17
-
18
- createRow: (item) =>
19
- @updateRow @constructor.blankRow.clone(), item
20
-
21
- updateRow: (row, item) ->
22
- row
23
-
24
- reloadRows: (rows, { sort } = { sort: null }) =>
25
- tbody = $ 'tbody', @table
26
-
27
- $('tr.loading', tbody).hide()
28
-
29
- if rows
30
- $('tr:not(.no-records):not(.loading)', tbody).remove()
31
-
32
- tbody.append if sort then @sortRows(rows, sort) else rows
33
-
34
- @updated()
35
-
36
- addRow: (row) =>
37
- $('tbody', @table).append row
38
- @updated()
39
-
40
- removeRow: (row) =>
41
- row.fadeOut =>
42
- row.remove()
43
- @updated()
44
-
45
- updated: =>
46
- $('tbody tr.no-records', @table)
47
- .toggle $('tbody tr:not(.no-records):not(.loading)', @table).length < 1
48
-
49
- getCheckedIds: =>
50
- (item.value for item in $('td:first-child input:checked', @table))
51
-
52
- # This should be fed a response from a JSON request for a paginated
53
- # collection.
54
- updatePagination: (response) =>
55
- @pagination = new Fustrate.Components.Pagination response
56
-
57
- $('.pagination', @root).replaceWith @pagination.generate()
@@ -1,25 +0,0 @@
1
- class Fustrate.Listenable
2
- constructor: ->
3
- @listeners = {}
4
-
5
- on: (eventNames, callback) =>
6
- for eventName in eventNames.split(' ')
7
- @listeners[eventName] = [] unless @listeners[eventName]
8
- @listeners[eventName].push callback
9
-
10
- @
11
-
12
- off: (eventNames) =>
13
- for eventName in eventNames.split(' ')
14
- @listeners[eventName] = []
15
-
16
- @
17
-
18
- trigger: =>
19
- [name, args...] = arguments
20
-
21
- return unless name and @listeners[name]
22
-
23
- event.apply(@, args) for event in @listeners[name]
24
-
25
- @
@@ -1,21 +0,0 @@
1
- class Fustrate.Object extends Fustrate.Listenable
2
- constructor: (data) ->
3
- @extractFromData data
4
-
5
- super
6
-
7
- # Simple extractor to assign root keys as properties in the current object.
8
- # Formats a few common attributes as dates with moment.js
9
- extractFromData: (data) =>
10
- @[key] = value for key, value of data
11
-
12
- @date = moment @date if @date
13
- @created_at = moment @created_at if @created_at
14
- @updated_at = moment @updated_at if @updated_at
15
-
16
- # Instantiate a new object of type klass for each item in items
17
- _createList: (items, klass, additional_attributes = {}) ->
18
- for item in items
19
- obj = new klass(item)
20
- obj[key] = value for key, value of additional_attributes
21
- obj
@@ -1,23 +0,0 @@
1
- class Fustrate.Record extends Fustrate.Object
2
- # Rails class name
3
- @class: null
4
-
5
- constructor: (data) ->
6
- super
7
-
8
- if typeof data is 'number' or typeof data is 'string'
9
- # If the parameter was a number or string, it's likely the record ID
10
- @id = parseInt(data, 10)
11
- else
12
- # Otherwise we were probably given a hash of attributes
13
- @extractFromData data
14
-
15
- reload: ->
16
-
17
- save: ->
18
-
19
- toObject: -> {}
20
-
21
- update: (data) =>
22
- @extractFromData data
23
- @save()
@@ -1,6 +0,0 @@
1
- #= require js-routes
2
- #= require moment
3
- #= require awesomplete
4
- #
5
- #= require_directory ./fustrate
6
- #= require_tree ./fustrate
@@ -1,7 +0,0 @@
1
- @import 'bourbon'
2
- @import 'font-awesome'
3
- @import 'awesomplete'
4
-
5
- @import 'fustrate/colors'
6
- @import 'fustrate/settings'
7
- @import 'fustrate/components/components'
@@ -1,76 +0,0 @@
1
- // 1795543d988d0fd9ca6237a5ac176f8e88d63990
2
- // sass-lint:disable-all
3
-
4
- [hidden]
5
- display: none
6
-
7
- .visually-hidden
8
- position: absolute
9
- clip: rect(0, 0, 0, 0)
10
-
11
- div.awesomplete
12
- display: block
13
- position: relative
14
-
15
- > input
16
- display: block
17
-
18
- > ul
19
- position: absolute
20
- left: 0
21
- z-index: 9
22
- min-width: 100%
23
- box-sizing: border-box
24
- list-style: none
25
- padding: 0
26
- border-radius: .3em
27
- margin: .2em 0 0
28
- background: hsla(0, 0%, 100%, .9)
29
- background: linear-gradient(to bottom right, white, hsla(0, 0%, 100%, .8))
30
- border: 1px solid rgba(0, 0, 0, .3)
31
- box-shadow: .05em .2em .6em rgba(0, 0, 0, .2)
32
- text-shadow: none
33
- max-height: 30vh
34
- overflow-x: scroll
35
-
36
- &[hidden],
37
- &:empty
38
- display: none
39
-
40
- > li
41
- position: relative
42
- padding: .2em .5em
43
- cursor: pointer
44
-
45
- &:not(:last-child)
46
- border-bottom: 1px solid rgba(64, 64, 64, .3)
47
-
48
- &:hover
49
- background: hsl(200, 40%, 80%)
50
- color: black
51
-
52
- &[aria-selected="true"]
53
- background: hsl(205, 40%, 40%)
54
- color: white
55
-
56
- mark
57
- background: hsl(65, 100%, 50%)
58
-
59
- li:hover &
60
- background: hsl(68, 100%, 41%)
61
-
62
- li[aria-selected="true"] &
63
- background: hsl(86, 100%, 21%)
64
- color: inherit
65
-
66
- @supports (transform: scale(0))
67
- div.awesomplete > ul
68
- transition: .3s cubic-bezier(.4, .2, .5, 1.4)
69
- transform-origin: 1.43em -.43em
70
-
71
- &[hidden],
72
- &:empty
73
- opacity: 0
74
- transform: scale(0)
75
- display: block
76
- transition-timing-function: ease
@@ -1,12 +0,0 @@
1
- $red: #914141
2
- $orange: #b26620
3
- $yellow: #b2a120
4
- $green: #70a854
5
- $blue: #3775a8
6
- $purple: #7857db
7
- $pink: #a933b1
8
- $brown: #8b5e36
9
- $grey: #606060
10
-
11
- $white: #fff
12
- $black: #000
@@ -1,19 +0,0 @@
1
- $base-line-height: 150% !default
2
-
3
- $small-limit: 40em
4
- // 64 is a bit too wide for half-screening on our monitors
5
- $medium-limit: 58em
6
-
7
- $screen: 'only screen'
8
-
9
- $landscape: '#{$screen} and (orientation: landscape)'
10
- $portrait: '#{$screen} and (orientation: portrait)'
11
-
12
- $small-up: $screen
13
- $small-only: '#{$screen} and (max-width: #{$small-limit})'
14
-
15
- $medium-up: '#{$screen} and (min-width:#{$small-limit + .063em})'
16
- $medium-only: '#{$screen} and (min-width:#{$small-limit + .063em}) and (max-width:#{$medium-limit})'
17
-
18
- $large-up: '#{$screen} and (min-width:#{$medium-limit + .063em})'
19
- $large-only: $large-up
@@ -1,36 +0,0 @@
1
- @import 'functions'
2
-
3
- @import 'typography'
4
- @import 'grid'
5
- @import 'buttons'
6
- @import 'forms'
7
-
8
- @import 'alerts'
9
- @import 'disclosures'
10
- @import 'dropdowns'
11
- @import 'flash'
12
- @import 'labels'
13
- @import 'modals'
14
- @import 'pagination'
15
- @import 'panels'
16
- @import 'popovers'
17
- @import 'tables'
18
- @import 'tabs'
19
- @import 'tooltips'
20
-
21
- +fustrate-typography
22
- +fustrate-grid
23
- +fustrate-buttons
24
- +fustrate-forms
25
- +fustrate-alerts
26
- +fustrate-disclosures
27
- +fustrate-dropdowns
28
- +fustrate-flash
29
- +fustrate-labels
30
- +fustrate-modals
31
- +fustrate-pagination
32
- +fustrate-panels
33
- +fustrate-popovers
34
- +fustrate-tables
35
- +fustrate-tabs
36
- +fustrate-tooltips
@@ -1,41 +0,0 @@
1
- $rem-base: 16px !default
2
-
3
- @function strip-unit($num)
4
- @return $num / ($num * 0 + 1)
5
-
6
- @function convert-to-rem($value, $base-value: $rem-base)
7
- $value: strip-unit($value) / strip-unit($base-value) * 1rem
8
-
9
- @if ($value == 0)
10
- @return 0
11
-
12
- @return $value
13
-
14
- @function rem-calc($values, $base-value: $rem-base)
15
- $max: length($values)
16
-
17
- @if $max == 1
18
- @return convert-to-rem(nth($values, 1), $base-value)
19
-
20
- $rem-values: ()
21
-
22
- @for $i from 1 through $max
23
- $rem-values: append($rem-values, convert-to-rem(nth($values, $i), $base-value))
24
-
25
- @return $rem-values
26
-
27
- =font-awesome($unicode, $padding-right: 3px, $spin: false)
28
- -moz-osx-font-smoothing: grayscale
29
- -webkit-font-smoothing: antialiased
30
- content: $unicode
31
- font-family: FontAwesome
32
- font-weight: 100
33
- text-rendering: auto
34
-
35
- @if $spin
36
- -webkit-animation: fa-spin 2s infinite linear
37
- animation: fa-spin 2s infinite linear
38
- display: inline-block
39
- margin-right: $padding-right
40
- @else
41
- padding-right: $padding-right
@@ -1,86 +0,0 @@
1
- $alert-padding: rem-calc(8) rem-calc(24) rem-calc(8) rem-calc(14) !default
2
- $alert-font-size: rem-calc(14) !default
3
- $alert-dark-color: #333 !default
4
- $alert-light-color: #fff !default
5
-
6
- =alert-color($bg: #eaeaea)
7
- $color: if(lightness($bg) > 70%, $alert-dark-color, $alert-light-color)
8
-
9
- background-color: $bg
10
- border-color: scale-color($bg, $lightness: -14%)
11
- color: $color
12
- text-shadow: 0 1px 1px scale-color($bg, $lightness: if(lightness($bg) < 70%, -70%, 70%))
13
-
14
- a,
15
- a:hover
16
- color: $color
17
- text-decoration: underline
18
-
19
- =fustrate-alerts
20
- .alert-box
21
- +alert-color
22
- border-style: solid
23
- border-width: 1px
24
- display: block
25
- font-size: $alert-font-size
26
- font-weight: normal
27
- margin-bottom: rem-calc(20)
28
- padding: $alert-padding
29
- position: relative
30
- transition: opacity .3s ease-out
31
-
32
- .panel &:last-child
33
- margin-bottom: 0
34
-
35
- li,
36
- p
37
- font-size: $alert-font-size
38
-
39
- & > :last-child
40
- margin-bottom: 0
41
-
42
- a.close
43
- color: $alert-dark-color
44
- font-size: rem-calc(22)
45
- line-height: 0
46
- margin-top: -(rem-calc(22) / 2)
47
- opacity: .6
48
- padding: 9px 6px 4px
49
- position: absolute
50
- right: rem-calc(4)
51
- text-decoration: none !important
52
- top: 50%
53
-
54
- &:hover,
55
- &:focus
56
- opacity: .8
57
-
58
- &.radius
59
- border-radius: 3px
60
-
61
- &.round
62
- border-radius: 8px
63
-
64
- &.plain
65
- +alert-color(lighten($grey, 57%))
66
-
67
- &.success,
68
- &.good,
69
- &.birthday
70
- +alert-color($success-color)
71
-
72
- &.alert
73
- +alert-color($alert-color)
74
-
75
- &.secondary
76
- +alert-color($secondary-color)
77
-
78
- &.warning
79
- +alert-color($warning-color)
80
-
81
- &.danger,
82
- &.error
83
- +alert-color($danger-color)
84
-
85
- &.info
86
- +alert-color($info-color)
@@ -1,99 +0,0 @@
1
- $button-padding: rem-calc(12) !default
2
- $button-font-size: rem-calc(12) !default
3
- $button-color: #fff !default
4
- $button-alt-color: #333 !default
5
-
6
- =button-base
7
- -webkit-appearance: none
8
- border: 0
9
- border-radius: 0
10
- cursor: pointer
11
- display: inline-block
12
- font-size: $button-font-size
13
- font-weight: normal
14
- line-height: normal
15
- margin: 0 0 rem-calc(5)
16
- position: relative
17
- text-align: center
18
- text-decoration: none
19
- transition: background .2s linear
20
-
21
- =button-size($padding: $button-padding, $sides: $button-padding * 1.5)
22
- padding: $padding $sides ($padding + rem-calc(1))
23
-
24
- =button-style($bg: $primary-color, $hover: true)
25
- $color: if(lightness($bg) < 70%, $button-color, $button-alt-color)
26
- $shadow-lightness: if(lightness($bg) < 70%, -85%, 85%)
27
-
28
- background: $bg
29
- color: $color
30
- text-shadow: 0 1px 1px scale-color($bg, $lightness: $shadow-lightness)
31
-
32
- .alert-box &
33
- color: $color
34
- text-decoration: none
35
-
36
- @if $hover
37
- &:hover,
38
- &:active
39
- background: if($hover == true, scale-color($bg, $lightness: -17%), $hover)
40
- color: $color
41
-
42
- .alert-box &:hover,
43
- .alert-box &:active
44
- color: $color
45
- text-decoration: none
46
-
47
- =fustrate-buttons
48
- button,
49
- .button
50
- +button-base
51
- +button-size
52
- +button-style
53
-
54
- &.expand
55
- width: 100%
56
-
57
- &.radius
58
- border-radius: 5px
59
-
60
- &.xlarge
61
- +button-size($button-padding * 1.8, $button-padding * 1.2)
62
- font-size: $button-font-size * 1.4
63
-
64
- &.large
65
- +button-size($button-padding * 1.3, $button-padding * 1.1)
66
- font-size: $button-font-size * 1.15
67
-
68
- &.small
69
- +button-size($button-padding * .6, $button-padding)
70
-
71
- &.tiny
72
- +button-size($button-padding * .4, $button-padding * .6)
73
- border-radius: 5px
74
- font-size: $button-font-size * .4
75
-
76
- &.danger,
77
- &.logout,
78
- &.destroy,
79
- &.deny,
80
- &.delete
81
- +button-style($red)
82
-
83
- &.save,
84
- &.submit,
85
- &.create,
86
- &.approve,
87
- &.success,
88
- &.close
89
- +button-style($green)
90
-
91
- &.plain,
92
- &.toggle-all,
93
- &.download,
94
- &.email,
95
- &.cancel
96
- +button-style(#eaeaea)
97
-
98
- h4 &
99
- vertical-align: middle
@@ -1,23 +0,0 @@
1
- $disclosure-title-font-size: rem-calc(12)
2
-
3
- =fustrate-disclosures
4
- .disclosure
5
- .disclosure-title
6
- +user-select(none)
7
- cursor: pointer
8
- font-size: $disclosure-title-font-size
9
-
10
- &::before
11
- content: '\25b8'
12
- display: inline-block
13
- width: 12px
14
-
15
- .disclosure-content
16
- display: none
17
-
18
- &.open
19
- .disclosure-title::before
20
- content: '\25be'
21
-
22
- .disclosure-content
23
- display: inherit
@@ -1,36 +0,0 @@
1
- $dropdown-color: #000 !default
2
- $dropdown-bg-color: #fff !default
3
- $dropdown-border-color: #ccc !default
4
- $dropdown-hover-bg-color: #f4f4f4 !default
5
-
6
- =fustrate-dropdowns
7
- .has-dropdown
8
- &::after
9
- content: '\25BE'
10
- padding-left: .5em
11
-
12
- & + .dropdown
13
- background: $dropdown-bg-color
14
- border: 1px solid $dropdown-border-color
15
- border-radius: 4px
16
- display: inline-block
17
- left: -9999px
18
- position: absolute
19
- width: auto
20
- z-index: 1
21
-
22
- a,
23
- span
24
- color: $dropdown-color
25
- cursor: pointer
26
- display: block
27
- font-size: .9rem
28
- padding: 3px 10px
29
-
30
- &:hover
31
- background: scale-color($dropdown-bg-color, $lightness: -5%)
32
-
33
- &.divider
34
- border-top: 1px solid $dropdown-border-color
35
- margin: 3px 0
36
- padding: 0
@@ -1,38 +0,0 @@
1
- $flash-color: #fff !default
2
- $flash-shadow-color: rgba(255, 255, 255, .4) !default
3
- $flash-bg-color: $primary-color !default
4
- $flash-error-bg-color: $danger-color !default
5
- $flash-success-bg-color: $success-color !default
6
-
7
- =fustrate-flash
8
- #flashes
9
- bottom: 0
10
- left: 0
11
- padding: .15rem .15rem 0
12
- position: fixed
13
- width: 100%
14
- z-index: 9900
15
-
16
- .flash
17
- +flash-color($flash-bg-color)
18
- box-shadow: 0 0 8px $flash-shadow-color
19
- color: $flash-color
20
- font-size: 1.25em
21
- line-height: 40px
22
- margin: 0 0 .15rem
23
- min-height: 40px
24
- opacity: .98
25
- padding: .2em 0
26
- position: relative
27
- text-align: center
28
-
29
- &.error
30
- +flash-color($flash-error-bg-color)
31
-
32
- &.success
33
- +flash-color($flash-success-bg-color)
34
-
35
- =flash-color($bg)
36
- background: $bg
37
- border: 1px solid scale-color($bg, $lightness: 20%)
38
- text-shadow: 0 1px 3px scale-color($bg, $lightness: -50%)