Skip to content

Commit

Permalink
Merge pull request #328 from harena-lab/development
Browse files Browse the repository at this point in the history
Several Harena adjusts and Terms Enhancement
  • Loading branch information
santanche authored Jan 31, 2022
2 parents 1211553 + ed60fdb commit 094846d
Show file tree
Hide file tree
Showing 26 changed files with 1,271 additions and 48 deletions.
465 changes: 465 additions & 0 deletions src/adonisjs/public/author/index-cell.html

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/adonisjs/public/author/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
<script src="/dccs/base/property-dcc.js"></script>
<script src="/dccs/base/connect-dcc.js"></script>


<script src="/dccs/components/data/dcc-model.js"></script>
<script src="/dccs/components/data/dcc-submit.js"></script>
<script src="/dccs/components/data/dcc-record.js"></script>
Expand Down Expand Up @@ -438,7 +437,7 @@ <h6 style="color:#808080;">Created by {{author_grade}}: {{username}} ({{institut
<div id="progress-artifacts"></div>
<div id="artifact-controls">
<input type="file" id="artifacts-select" name="artifacts-select" multiple="multiple"
accept="image/png, image/jpeg, image/svg, audio/mpeg, video/mp4, video/webm">
accept="image/png, image/jpeg, image/svg+xml, audio/mpeg, video/mp4, video/webm">
<dcc-button xstyle="in" topic="generator/activate/artifact-knot" label="PLACE IN KNOTS"></dcc-button>
</div>
</div>
Expand Down
8 changes: 6 additions & 2 deletions src/adonisjs/public/dccs/base/primitive-dcc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ class PrimitiveDCC extends HTMLElement {
}

_findAggregator(agClass) {
let parent = this.parentNode
let parent = (this.parentNode != null)
? this.parentNode
: ((this instanceof DocumentFragment) ? this.host : null)
while (parent != null && !(parent instanceof agClass))
parent = parent.parentNode
parent = (parent.parentNode != null)
? parent.parentNode
: ((parent instanceof DocumentFragment) ? parent.host : null)
return parent
}

Expand Down
17 changes: 16 additions & 1 deletion src/adonisjs/public/dccs/base/scope-dcc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ class ScopeDCC extends PrimitiveDCC {
connectedCallback () {
super.connectedCallback ()
this._bus = MessageBus.create(this.id)
if (this.externalize) {
this._bus.bridge = MessageBus.i
MessageBus.i.bridge = this._bus
}
}

static get observedAttributes () {
return ['id']
return ['id', 'externalize']
}

get id () {
Expand All @@ -16,6 +20,17 @@ class ScopeDCC extends PrimitiveDCC {
this.setAttribute('id', newValue)
}

get externalize () {
return this.hasAttribute('externalize')
}

set externalize (isAuthor) {
if (isAuthor)
this.setAttribute('externalize', '')
else
this.removeAttribute('externalize')
}

get bus () {
return this._bus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ class RuleDCCCellPair extends RuleDCCCellNeighbor {
nc = (nc < 0) ? spaceState.ncols - 1 : nc % spaceState.ncols
}
if (nr >= 0 && nr < spaceState.nrows &&
nc >= 0 && nc < spaceState.ncols) { triggered = this._computeTransition(spaceState, row, col, nr, nc) }
nc >= 0 && nc < spaceState.ncols)
triggered = this._computeTransition(spaceState, row, col, nr, nc)
}
}
return triggered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class RuleDCCTransition extends RuleDCCCell {
**********/

static get observedAttributes () {
return RuleDCCCell.observedAttributes.concat(['transition'])
return RuleDCCCell.observedAttributes.concat(['transition', 'topic'])
}

get transition () {
Expand All @@ -23,6 +23,14 @@ class RuleDCCTransition extends RuleDCCCell {
this._decomposeTransition(newValue)
}

get topic () {
return this.getAttribute('topic')
}

set topic (newValue) {
this.setAttribute('topic', newValue)
}

_decomposeTransition (transition) {
this._oldSource = transition[0]
this._oldTarget = transition[1]
Expand Down Expand Up @@ -120,6 +128,8 @@ class RuleDCCTransition extends RuleDCCCell {
}
}
}
if (this.hasAttribute('topic') && triggered)
this._publish(this.topic)
return triggered
}
}
45 changes: 36 additions & 9 deletions src/adonisjs/public/dccs/components/control/dcc-compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DCCCompute extends DCCBase {
this._subscribe('compute/updated/' + this.dependency,
this._dependencyCompleted)
this._publish('compute/status/' + this.dependency)
} else if (this._compiled != null && this.active)
} else if (this._compiled != null && (this.active || this.autorun))
await this._newExpressionUpdate()
}

Expand All @@ -50,7 +50,15 @@ class DCCCompute extends DCCBase {

async _subscribeVariables () {
await this._unsubscribeVariables()
this._subsVariables = DCCCompute.filterVariables(this._compiled, false)
this._subsVariables =
DCCCompute.filterVariables(this._compiled, false, null)
if (this._condition != null) {
const condition = DCCCompute.
filterVariables(this._condition, false, this._compiled)
for (const c of condition)
if (!this._subsVariables.includes(c))
this._subsVariables.push(c)
}
for (let v of this._subsVariables)
this._subscribe('var/set/' + v.replace(/\./g, '/'), this.update)
}
Expand All @@ -66,12 +74,14 @@ class DCCCompute extends DCCBase {
_dependencyCompleted () {
this._unsubscribe('compute/updated/' + this.dependency,
this._dependencyCompleted)
this._newExpressionUpdate()
if (this.active || this.autorun)
this._newExpressionUpdate()
}

async _newExpressionUpdate () {
await this.update()
await this._subscribeVariables()
if (this.active)
await this._subscribeVariables()
}

/*
Expand All @@ -80,7 +90,7 @@ class DCCCompute extends DCCBase {

static get observedAttributes () {
return DCCBase.observedAttributes.concat(
['condition', 'expression', 'active', 'dependency'])
['condition', 'expression', 'active', 'autorun', 'dependency'])
}

get condition () {
Expand All @@ -104,7 +114,7 @@ class DCCCompute extends DCCBase {
this._newExpressionUpdate()
}

// defines if the display is activelly updated
// defines if the expression is activelly updated
get active () {
return this.hasAttribute('active')
}
Expand All @@ -117,6 +127,19 @@ class DCCCompute extends DCCBase {
}
}

// defines if the expression run at start
get autorun () {
return this.hasAttribute('autorun')
}

set autorun (isActive) {
if (isActive) {
this.setAttribute('autorun', '')
} else {
this.removeAttribute('autorun')
}
}

get dependency () {
return this.getAttribute('dependency')
}
Expand Down Expand Up @@ -330,15 +353,16 @@ class DCCCompute extends DCCBase {
return result
}

static filterVariables (compiledSet, includeAssigned) {
static filterVariables (compiledSet, includeAssigned, compiledAssignment) {
let assigned = []
if (!includeAssigned)
assigned = DCCCompute.filterAssignedVariables(compiledSet)
assigned = DCCCompute.filterAssignedVariables(
(compiledAssignment == null) ? compiledSet : compiledAssignment)
let variables = []
for (let s of compiledSet) {
for (let c of s[1])
if (c[0] == DCCCompute.role.variable && !variables.includes(c[1]) &&
!assigned.includes[c[1]])
!assigned.includes(c[1]))
variables.push(c[1])
}
return variables
Expand Down Expand Up @@ -426,6 +450,9 @@ class DCCCompute extends DCCBase {
case 'abs':
stack.push(Math.abs(stack.pop()))
break
case 'round':
stack.push(Math.round(stack.pop()))
break
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/adonisjs/public/dccs/components/visual/dcc-expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class DCCExpression extends DCCVisual {
}

async connectedCallback () {
super.connectedCallback()
// <TODO> provisory solution due to message ordering
// this._updated = false

Expand Down Expand Up @@ -34,6 +35,8 @@ class DCCExpression extends DCCVisual {
// also monitors all messages
if (this.active) {
this.stateChanged = this.stateChanged.bind(this)
console.log('=== component bus')
console.log(this._bus)
this._subscribe('input/state/#', this.stateChanged)
this._stateValues = {}
}
Expand All @@ -60,8 +63,6 @@ class DCCExpression extends DCCVisual {

this._setPresentation(this)
this._presentationIsReady()

super.connectedCallback()
}

async _showResult () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class DCCLivelyTalk extends DCCVisual {
this.character : 'images/character.png'
this._speech = (this.speech != null) ? this.speech : ''
this._buildVisual()
super.connectedCallback()
}

_buildVisual () {
Expand Down
12 changes: 6 additions & 6 deletions src/adonisjs/public/dccs/components/visual/dcc-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
***********/
class DCCReport extends DCCVisual {
connectedCallback () {
super.connectedCallback()
this.presentReport = this.presentReport.bind(this)
this._subscribe('/report', this.presentReport)
this._publish('/report/get')
this._subscribe('report', this.presentReport)
this._publish('report/get')
console.log('report solicitado')
super.connectedCallback()
}

presentReport (topic, message) {
Expand Down Expand Up @@ -62,12 +62,12 @@ class DCCReport extends DCCVisual {
.dsty-icon-box {
flex: 64px;
max-width: 74px;
}
}
.dsty-icon {
object-fit: contain;
max-width: 64px;
max-height: 100%;
}
}
.dsty-details {
display: flex;
flex-direction: column;
Expand All @@ -89,7 +89,7 @@ class DCCReport extends DCCVisual {
</style>
<div id="presentation-dcc" class="dsty-record dsty-border">
<div id="record-images" class="dsty-images-container">
[images]
[images]
</div>
<div class="dsty-details" class="dsty-border">
[entries]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class DCCStateSelect extends DCCVisual {
}

async connectedCallback () {
super.connectedCallback()
DCCStateSelect.templateElements =
"<style> @import '" +
Basic.service.themeStyleResolver('dcc-state-select.css') +
Expand Down Expand Up @@ -62,7 +63,6 @@ class DCCStateSelect extends DCCVisual {
sourceType: DCCStateSelect.elementTag,
content: this.innerHTML
})
super.connectedCallback()
}

disconnectedCallback () {
Expand Down
14 changes: 6 additions & 8 deletions src/adonisjs/public/dccs/components/web/dcc-dhtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@ class DCCDHTML extends DCCBase {

this._renderHTML()

if (this.innerHTML.length > 0) {
this._originalHTML = this.innerHTML
this.innerHTML = ''
}
this._observer = new MutationObserver(this._contentUpdated)
this._observer.observe(this,
{attributes: true, childList: true, subtree: true})
this._contentUpdated()

if (this.hasAttribute('autoupdate')) {
let record = await this._request('var/get/*', null, null, true)
Expand Down Expand Up @@ -69,10 +66,11 @@ class DCCDHTML extends DCCBase {
}

_contentUpdated(mutationsList, observer) {
if (this.innerHTML.length > 0) {
this._originalHTML += this.innerHTML
this.innerHTML = ''
}
let fragment = this.innerHTML
while (fragment.length != this.innerHTML.length)
fragment = this.innerHTML
this.innerHTML = ''
this._originalHTML += fragment
this._renderHTML()
}

Expand Down
Loading

0 comments on commit 094846d

Please sign in to comment.