Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Levelbuilder Clean Up: Remove all edit file #35162

Merged
merged 8 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ describe('entry tests', () => {
'datasets/edit_manifest':
'./src/sites/studio/pages/datasets/edit_manifest.js',
levelbuilder: './src/sites/studio/pages/levelbuilder.js',
'levels/editors/_all': './src/sites/studio/pages/levels/editors/_all.js',
'levels/editors/_applab':
'./src/sites/studio/pages/levels/editors/_applab.js',
'levels/editors/_blockly':
Expand All @@ -603,6 +602,12 @@ describe('entry tests', () => {
'levels/editors/_droplet':
'./src/sites/studio/pages/levels/editors/_droplet.js',
'levels/editors/_dsl': './src/sites/studio/pages/levels/editors/_dsl.js',
'levels/editors/fields/_callouts':
'./src/sites/studio/pages/levels/editors/fields/_callouts.js',
'levels/editors/fields/_preload_assets':
'./src/sites/studio/pages/levels/editors/fields/_preload_assets.js',
'levels/editors/fields/_special_level_types':
'./src/sites/studio/pages/levels/editors/fields/_special_level_types.js',
'levels/editors/fields/_video':
'./src/sites/studio/pages/levels/editors/fields/_video.js',
'levels/editors/_gamelab':
Expand Down
19 changes: 19 additions & 0 deletions apps/src/sites/studio/pages/levelbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ import _ from 'lodash';
import codemirror from 'codemirror';
import copyToClipboard from '@cdo/apps/util/copyToClipboard';
import {convertXmlToBlockly} from '@cdo/apps/templates/instructions/utils';
import $ from 'jquery';

$(document).ready(initPage);

function initPage() {
function make_selection_handler(flag) {
return function(e) {
e.preventDefault();
const options = $(this)
.parent()
.siblings('select')
.children('option');
options[flag ? 'attr' : 'removeAttr']('selected', true);
};
}

$('.select_all').click(make_selection_handler(true));
$('.select_none').click(make_selection_handler(false));
}

window.levelbuilder = window.levelbuilder || {};
_.extend(window.levelbuilder, {
Expand Down
70 changes: 0 additions & 70 deletions apps/src/sites/studio/pages/levels/editors/_all.js

This file was deleted.

34 changes: 34 additions & 0 deletions apps/src/sites/studio/pages/levels/editors/fields/_callouts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* global levelbuilder */
import $ from 'jquery';

$(document).ready(initPage);

function initPage() {
levelbuilder.jsonEditor('#callout_editor', {
Comment on lines +1 to +7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine for now, but we should think about getting rid of the pattern of defining globals in levelbuilder.js in the future.

json_textarea: '#level_callout_json',
add_button: '#add_callout',
remove_button: '.remove_callout',
value_space: '.callout_space',
template: '.json_template',
form_container: '#all_callouts_editor',
wrapper: '.json_editor',
model: {
localization_key: '',
callout_text: '',
element_id: '',
on: '',
qtip_config: {
codeStudio: {
canReappear: false,
dropletPaletteCategory: ''
},
style: {classes: ''},
position: {
my: '',
at: '',
adjust: {x: 0, y: 0}
}
}
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import $ from 'jquery';

$(document).ready(initPage);

function initPage() {
$('#plusPreloadAssetList').on('click', () => {
$('#plusPreloadAssetList')
.prev()
.clone()
.insertBefore('#plusPreloadAssetList');
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import $ from 'jquery';

$(document).ready(initPage);

function initPage() {
$('#plusAnswerContainedLevel').on('click', () => {
$('#plusAnswerContainedLevel')
.prev()
.clone()
.insertBefore('#plusAnswerContainedLevel');
});
}
10 changes: 9 additions & 1 deletion dashboard/app/views/levels/edit.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
%h1= @page_title = @level.new_record? ? "New #{@level.class.to_s} level" : "Editing #{@level.name}"

- content_for(:head) do
= stylesheet_link_tag 'css/levelbuilder', media: 'all'
= stylesheet_link_tag 'jquery.handsontable.full', media: 'all'
%script{src: webpack_asset_path('js/levelbuilder.js')}
= javascript_include_tag 'jquery.handsontable.full'

= form_for [@level], method: @level.new_record? ? :post : :patch, remote: true do |f|
= f.hidden_field :type, value: @type_class.to_s.presence || @level.type
Expand Down Expand Up @@ -37,9 +40,11 @@
// Note that many DSL levels also use this partial. See _dsl.html.haml
= render partial: 'levels/editors/fields/teacher_only_markdown', locals: {f: f} if (@level.include_teacher_only_markdown_editor?)
= render partial: 'levels/editors/code_area', locals: {f: f} if (@level.uses_droplet? || @level.is_a?(Blockly)) && !@level.is_a?(NetSim)
= render partial: 'levels/editors/fields/video', locals: {f: f} unless (@level.is_a?(DSLDefined) || @level.is_a?(CurriculumReference) || @level.is_a?(ExternalLink) || @level.is_a?(FreeResponse) || @level.is_a?(Odometer))
= render partial: 'levels/editors/fields/bubble_choice_sublevel', locals: {f: f} unless (@level.is_a?(BubbleChoice) || @level.is_a?(CurriculumReference) || @level.is_a?(EvaluationMulti) || @level.is_a?(StandaloneVideo) || @level.is_a?(ContractMatch) || @level.is_a?(External) || @level.is_a?(Unplugged))
= render partial: 'levels/editors/fields/special_level_types', locals: {f: f} if (@level.is_a?(Blockly) || @level.is_a?(Weblab) || @level.is_a?(FreeResponse)) && !@level.is_a?(NetSim)
= render partial: 'levels/editors/weblab', locals: {f: f} if @level.is_a? Weblab
= render partial: 'levels/editors/unplugged', locals: {f: f} if @level.is_a? Unplugged
= render partial: 'levels/editors/all', locals: {f: f}
= render partial: 'levels/editors/flappy', locals: {f: f} if @level.is_a? Flappy
= render partial: 'levels/editors/bounce', locals: {f: f} if @level.is_a? Bounce
= render partial: 'levels/editors/studio', locals: {f: f} if @level.is_a? Studio
Expand All @@ -56,6 +61,9 @@
= render partial: 'levels/editors/netsim', locals: {f: f} if @level.is_a? NetSim
= render partial: 'levels/editors/odometer', locals: {f: f} if @level.is_a? Odometer
= render partial: 'levels/editors/vigenere', locals: {f: f} if @level.is_a? Vigenere
= render partial: 'levels/editors/fields/preload_assets', locals: {f: f} if @level.is_a?(Applab) || @level.is_a?(Gamelab)
= render partial: 'levels/editors/fields/hide_share_and_remix', locals: {f: f} if ((@level.uses_droplet?) || @level.is_a?(Blockly) || @level.is_a?(Weblab)) && !@level.is_a?(NetSim)
= render partial: 'levels/editors/fields/callouts', locals: {f: f} unless (@level.is_a?(CurriculumReference) || @level.is_a?(DSLDefined))
= render partial: 'levels/editors/fields/audit_log', locals: {f: f} unless @level.is_a? EvaluationMulti
= render partial: 'levels/editors/fields/deprecated', locals: {f: f} unless @level.is_a? EvaluationMulti
.field
Expand Down
15 changes: 0 additions & 15 deletions dashboard/app/views/levels/editors/_all.html.haml

This file was deleted.

3 changes: 3 additions & 0 deletions dashboard/app/views/levels/editors/fields/_callouts.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- content_for :body_scripts do
%script{src: webpack_asset_path('js/levels/editors/fields/_callouts.js')}

%h1.control-legend{data: {toggle: "collapse", target: "#callout_editor"}}
Callouts

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- content_for :body_scripts do
%script{src: webpack_asset_path('js/levels/editors/fields/_preload_assets.js')}

%h1.control-legend{data: {toggle: "collapse", target: "#preload_asset"}}
Preload Assets

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
- content_for :body_scripts do
%script{src: webpack_asset_path('js/levels/editors/fields/_special_level_types.js')}

%h1.control-legend{data: {toggle: "collapse", target: "#special-levels"}}
Special Level Types

Expand Down